Posted by & filed under Programming.

Often times while developing web pages you find yourself needing to know how the server is set up. If you have been developing in PHP for any length of time, certainly you know the command phpinfo(). For those of you that have not tried this, you’re in for a surprise at how much it tells you.

What’s the point?
The phpinfo() command outputs all sorts of information about PHP and the server it’s on. If you need to find out a specific setting on a server, or just have a voyeuristic curiosity, this is a good routine to put in your toolbox.

How to use
To use just drop the command phpinfo() into a PHP script. Then, just browse to the script. The page will show all sorts of information.

Options
phpinfo() takes one argument. It can be:
INFO_GENERAL – Shows the config file location, build date, operating system, and web server.
INFO_CREDITS – Shows credits for the PHP program
INFO_CONFIGURATION – Shows current local and master values for directives in php.ini
INFO_MODULES – Lists the loaded modules and their settings
INFO_ENVIRONMENT – Lists information from the variable $_ENV
INFO_VARIABLES – Lists predefined variables from $_ENV, $_GET, $_POST, $_SERVER, and $_COOKIES
INFO_LICENSE – Shows the PHP license
INFO_ALL – Shows everything above. This is the default.

A few of the more useful points

  • System – The operating system of the server
  • Configuration File (php.ini) Path – Self explanatory
  • All the PHP core directives are useful if you need to know :-)
  • session.save_path – Where the session data is stored

To be fair, these few are the ones I use when I’m working on a new host. The variable sections are very useful when I forget how to get the host IP address or port or things like that.

Comments are closed.