Posts Tagged ‘phpinfo’
Discovering more with phpinfo
8/18/2010 9:30 AM By Jeff BThis one’s a quickie way to determine whether or not PHP is installed on your host, and if so, what version it is and what settings are enabled. You’ll want to create a new file; name it whatever you like, but test.php is probably a good name. Copy this one line to it:
<?php phpinfo(); ?>
Save it and upload it to the server you’d like to test. Then go ahead and visit test.php on your server, and you should see something similar to this:

This generated page will go on for quite a bit, showing you lots of information in a series of tables. You can discover some very useful information about the PHP setup on your host. First, note the version. You want to be running at least version 5.0, and if not, you should ask your host to either upgrade your machine or move you to a more up-to-date box. PHP 5.0 has been out since 2004, so there is no excuse for your host not at least being that up-to-date, and preferably, they should be running 5.3.2, the current stable release.
Additionally, if you continue looking on, you’ll discover the “Configuration” table, which shows us way too much info, but some useful things to note are:
- Is
display_errorsenabled? - What is
memory_limitset to? - What is
post_max_sizeset to? - What is
upload_max_filesizeset to? - Is
safe_modeenabled?
The first, display_errors, does exactly that: when enabled, PHP errors are rendered in the browser and shown to you. This is good for you as a developer, but once the item in question is finished and developed, this should be disabled if possible, as it can provide outsiders with far more information than they should have.
The memory_limit is a size, usually in MB (indicated with an “M”), for how much memory PHP can consume while running. The bigger this is, the bigger your scripts can be before they choke. Most servers default this to 8 or 16 MB, and increasing it can often solve a host of issues with larger scripts and file uploading. Which brings me to the next two configuration items.
The post_max_size and upload_max_filesize items determine how large of a file you can upload using PHP. This is especially important when using a CMS, like WordPress or ExpressionEngine, as the default limit is 2MB, which can be far too small if you’re uploading movies, PDFs, or large images to your site using your CMS.
The last one, safe_mode, is a bit tricky to explain, as it does a lot of different things, but simply put, it limits PHP’s powers in an effort to combat abuse and intrusion attempts. This limiting, however, can cause many headaches with PHP’s own normal abilities, and generally, life is easier all around if it can be left off.
You can continue on down the page, seeing all the different modules your server’s PHP has loaded (and their configuration), but the last set of interesting data will be the “PHP Variables” table. This is a set of global variables (that is, variables that are available throughout any PHP you write on this server). Examine these to learn some more about what PHP can determine, and remember that these may come in handy later.








Subscribe by RSS