25 Aug 09 PHP Programming Tutorial: Version and Installation



Here you will learn how to test your installation using the phpinfo() statement.

1. The first thing to do is make sure WampServer is running. You should see the icon in your taskbar.

WampServer icon

WampServer icon

Make sure to turn it on by selecting the “Put Online” option. After it is online, you should see it looks something like this:

WampServer Online

WampServer Online

Notice the red square around the words “Put Offline.” It’s giving us the option to put it offline because it’s currently online, which is what we wanted, of course.

2. Load your Web browser, like Mozilla Firefox, and go to: http://localhost

If your server is working, you see a page load. This means that our server is processing the files from our hard drive and displaying them to our browser. Perfect!

These files are loading from the “www” directory in your Wamp folder installation. If you followed my installation tutorial, this address should be: c:\wamp\www

3. Go into the “www” directory and create a new folder called “introduction”. Go back to your web browser and refresh the http://localhost page. You should now see the “introduction” folder listed under Your Projects.

Directory structure

Directory structure

4. Load your Code/Text Editor, like Notepad++, and type in:

<?php phpinfo(); ?>

Save this page to the “introduction” directory. Name the file: phpinfo.php

PHP file save as dialog

PHP file save as dialog

It is important to give the file an extension of .php. If you name it phpinfo.html, then the Web server thinks it’s a HTML page and won’t bother using any PHP code in the file.

This is your first PHP code. Congrats! This is a basic example of how all coding works.

1. You start with the beginning PHP tag: <?php
2. Then you write in your code.
3. And you stop with the ending PHP tag: ?>

When the Web server gets the file and sees the .php extension, it checks for PHP tags. These tags tell the web server, “Hey! I’ve got some code in here. Do something with it.”

5. Go back to your Web browser and go to: http://localhost/introduction/phpinfo.php

Web browser image

Web browser image

If all goes well, the phpinfo() function will load a ton of information about your current version of PHP. This is a great way to test your local server. Usually you do not want to upload this file to a public web site since it gives a lot of information about your server and could be a security risk.

Continue to PHP Statements.

Go back to PHP Programming: The Basics.

Tags: , , ,

Reader's Comments

  1. |

    Hi,
    When I go to my “http://localhost/” I get the Page Load Error. I turned on my wampserver and have tryed restarting all services but no luck. Can you point me in the right direction?
    Thanks for the tutorials,
    David

    Reply to this comment
    • |

      Hi David,

      I added a new screenshot to #1 at the top of this tutorial. Please verify your WampServer menu looks like this. If it does and it still doesn’t load, I suggest rebooting your computer and restarting WampServer.

      Let me know how it goes! If that doesn’t work we can try some more troubleshooting. Thanks.

      Reply to this comment
  2. |

    ok I did everything you said on here, however when I go to the http://localhost/introduction/phpinfo.php nothing is happening it say’s “This link appears to be broken” I’ve also rebooted my laptop as well.

    I’am lost help please.

    Reply to this comment
    • |

      It might be a number of things. Some things I would try is:

      1. Verify the servers are “Put Online.”

      2. Try a different browser.

      3. Look through the log files to see if there was an error. I believe these are accessible from the Apache menu.

      4. Uninstall WAMP and try again. If it doesn’t work you may also try XAMPP, which is a good alternative to WAMP.

      I hope this helps!

      Reply to this comment
  3. |

    I had trouble getting WAMP to start properly – saying something about the service could not be started and my localhost page showing up as a white screen.

    After looking on some PHP sites I found that something was already using the port needed – Skype in my case.

    Reply to this comment

Leave a Comment