phpinfo()

One of the many wonders of PHP is this little piece of code:

php:


<?php
  phpinfo()
?>


Just copy the code above and name it anything you want; phpinfo.php, myserver.php or whatever.php. Upload it to your webserver and bring it up through your favourite browser and get a quick overview of how your server and PHP are set up.

Why do I need phpinfo()

What I usually do (especially when I move web hosts) is to bring this file up once and save a copy to my HDD. Then I spend days trying to set Apache and PHP on my PC to match the settings on the live server. This way I am 95% certain that the PHP code I write and test on my PC, will also work on my live site.

Apache and PHP environment variables list

Another good use for this file is when you are trying to figure out which Environment Variables to use best with your PHP codes, such as:

code:
$_SERVER['SCRIPT_FILENAME']
$_SERVER['QUERY_STRING']
$_SERVER['REQUEST_URI']
$_SERVER['SCRIPT_NAME']

Though it may seem that these variables share similar values, there are important subtle differences.

Furthermore, if you get to phpinfo.php off a link on another web page (OR a link with a query string OR off a posted form), there should be additional variables added to this list, like:

code:
$_SERVER['HTTP_REFERER']
$_GET['vars_in_a_url']
$_POST['vars_off_a_form']

TOP

Do you find it easy to navigate through this site?

 Yes

 No

 Where am I?