What is phpinfo()?

Posted on: August 14th, 2015 by BuildMyWeb 1 Comment

If you are going to be programming PHP logic into your websites and web applications, you will eventually find a use for phpinfo(). It is a function that outputs a large amount of data on the state of php as it is installed on your server. PHP extensions, the PHP version, paths, server configuration options, and the like can all be found in this data. That can be very useful. Particularly when making decisions on selecting solutions. You’ll want to know what your options are and what is available to you.

In a recent project I was working on, we wanted to be able to dynamically crop and resize images that users would be uploading to the server. We accomplished this by leveraging the GD Library. Before deciding, we wanted to make sure the library was indeed installed on our production server. We did so by way of the phpinfo() function.


Create a new php file and call it anything you like. Something like phpinfo.php will do nicely. In that file, place your opening and closing php tags and then inside of them, write the function: phpinfo();. That’s it. Nothing more. Upload that file to your server and then navigate to the file in your browser: http://mydomain.com/phpinfo.php.


The above is a screenshot of the section I was looking for in this instance. When the file loaded, I hit ctrl-f to open the search field in my Firefox browser window and typed ‘GD’, then ‘Enter’. The search brought me down to the section you see above, confirming that the GD library was indeed installed and ready for use.

One word of caution, be sure to remove the phpinfo.php file when you are done with it as it is not the type of information you want to share with the public.


One Response

Leave a Reply