If you are running PHP scripts on your website, it’s often useful to know details about the version of PHP that’s running and how it’s configured. There is an easy way to get this information.
Create a new file with a .php
extension—say phpinfo.php
. Inside that file, simply type this code:
<? phpinfo(); ?>
Now, upload this file to your website. It needs to be located in a publicly accessible part of your site (such as the root folder) so that you can access it through your browser.
Let’s say you do place it in your root folder. In that case, it will be located at an address like your-site.com/phpinfo.php
. Enter this address in your web browser.
Now, one of two things will happen.
If you simply see the code you typed into the file (that is, <? phpinfo(); ?>
), then you are in a spot of bother. It means that PHP is not installed on your server. But that’s rare.
More likely, you will see a long, colorful page, full of all sorts of information about the version of PHP installed on your server and lots of other information about its configuration. From the PHP Manual:
This includes information about PHP compilation options and extensions, the PHP version, server information and environment (if compiled as a module), the PHP environment, OS version information, paths, master and local values of configuration options, HTTP headers, and the PHP License.
Warning
Once you’ve gathered the information you need, it’s best to delete this file from your server again. Hackers with evil intentions could make use of this information to get up to no good. So don’t give them the chance. :-)