Create a PHP information page

What we’re doing in this task:

We’re making our first PHP page.

We’re seeing how the .php file extension works.

We’re watching the HTTP request process work for PHP pages (as discussed earlier).

We’re making sure we can connect to the PHP engine (the application server software) on the server.

And we’re also learning how to create a simple test page that you can use with any web server, to see if PHP is installed and running.

1. Create a new page, named phpinfo.php

2. Open the file and go to Code view.

3. Select and delete all code there.

4. Type in this new code:

<?php

phpinfo();

?>

5. Preview locally (by pressing F12). What do you get?

6. Upload the page to the remote site and view it as a served page. The URL will look like this:

http://192.168.1.109/~webuser00/dwphp/test.php

We have contacted the PHP server … what about this file made that happen?

A. The .php File Extension

Try changing the file name to phpinfo.html and uploading it and viewing it.

B. The PHP tags

Try changing the file name back to phpinfo.php, deleting the opening and closing tags, and uploading for viewing.

C. And of course valid PHP

Try putting some random stuff in there, and see what you get back — this is often what happens when there’s an error .

Also try simple case sensitivity or spacing errors, to see color coding in action.

With all of those things in place, the HTTP server passed what was inside the tags to the PHP server.

(NOTE:Dreamweaver color coding supports this, only showing up when everything is in place.)

Why did we do this?

If you get the PHP info page, that means PHP is running on the server and that you have successfully connected to it.

It tells you lots of things about PHP that we don’t need to worry about … but specific configuration information that you might need when you’re a more advanced PHP developer.

We can also see how the dynamic process works:

send PHP instructions

get processed HTML back

And we can see what elements a PHP page needs (the file extension, the PHP tags)

And we need a valid PHP function … and we’ve seen what some valid PHP code looks like:

a function has ()

a line ends with ;

code is case sensitive