PHP & MySQL® Web Development All-in-One Desk Reference for Dummies®
by Janet Valade, Tricia Ballad, Bill Ballad
2.6. Testing PHP
To test whether PHP is installed and working, follow these steps:
Find the directory in which your PHP programs need to be saved.
This directory and the subdirectories under it are your Web space. Apache calls this directory the document root. The default Web space for Apache is htdocs in the directory where Apache is installed. For IIS, it's Inetpub\wwwroot. In Linux, it might be /var/www/html. The Web space can be set to a different directory by configuring the Web server. If you're using a Web hosting company, the staff will supply the directory name.
Create the following file somewhere in your Web space with the name test.php.
<html> <head> <title>PHP Test</title> </head> <body> <p>This is an HTML line</p> <?php echo "<p>This is a PHP line</p>"; phpinfo(); ?> </body></html>

The file must be saved in your Web space for the Web server to find it.
Run the test.php file created in Step 2. That is, type the host name of your Web server into the browser address window, followed by the name of the file (for example, www.myfinecompany.com/test.php).
If your Web server, PHP, and the test.php file are on the same computer that you're testing from, you can type localhost/test.php.

For the file to be processed by PHP, you need to access the file through the Web server — not ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access