3. XAMPP: PHP website Test, Tutorial
PHP website tested in XAMPP
PHP websites require a web server to be tested because PHP scripts are not executed in Browser but on the Server; therefore, you need XAMPP installed, and the Apache web server running.For example purpose, we will run 2 tests:
- test 1: the PHP website is tested straight in browser
- test 2: the PHP website is tested from server
Result: see the difference: on server the php code is executed; in browser it isn't; the display ⁄ functionality is not the same in the 2 cases
Video demonstration XAMPP: PHP website test
3. XAMPP PHP website Test, Tutorial
min | video details |
---|---|
00:03 | access localhost |
00:06 | open the browser |
00:10 | testing a Php website: a) straight in browser (right side of the screen) b) from the server (left side of the screen) |
00:13 | open the php folder |
00:15 | the php website contains: 1 index.php file, 2 png images, 1 css file, and a 'menu' folder grouping 4 php pages, one for each menu |
00:24 | BROWSER test: |
00:24 | test in browser: simply drag and drop the php folder containing the website and click the index.php file |
00:29 | NOT OK: the display of the php website is incomplete (home page text is missing) and we can't access menu's pages because the php code is not executed; php scripts are executed on server; php is server side scripting, php needs a server! That's why we installed XAMPP to be able to test php scripts (code) |
00:39 | SERVER test: |
00:39 | now we will test it from server: Step1: add it to htdocs directory Step2: access it from server (http://localhost..) |
00:40 | Step1: open htdocs directory by clicking the shortcut icon If you want to know how to create a desktop shortcut icon to your htdocs directory, watch a video demo here |
00:42 | Step1: add your php website to htdocs directory |
00:49 | Step2: test your php website on server |
00:51 | the php website displays |
00:59 | Note: the display ⁄functionality of a php website is NOT identical on both sides; the php website needs a server to be tested because php is a server-side scripting language |
01:02 | - test from server: see the content corresponding to the home page - test in browser: the content corresponding to the home page doesn't show |
01:33 | checking the page source code for both displays (left side -from server) vs (right side -in browser) |
01:50 | left side OK: the server executed the php code right side NOT ok - the browser could not execute the php code and thus it displays in page source code |
02:15 | the menu1.html file and menu1.php files, both output the same content, now let's check their code |
02:21 | in .html file you need 30 lines while in .php file all you need is one => that's one of the php advantages |