Home » Programming » PHP » Php Phpinfo

How To Get Info About your PHP Environment Using phpinfo()

This article will explain what the phpinfo() function does and how to use it to get information about the PHP environment on your system.

Many PHP packages and platforms (like WordPress, Laravel, and Symfony) have system requirements beyond what is included in the base PHP installation on most systems.

These required modules include things like support for encryption, database support, and the ability to make HTTP requests from within PHP.

To ensure that your PHP environment meets these conditions before trying to run the software, you need to know a bit about it.

That’s what phpinfo() is for – it tells you all about your PHP installation – what modules are installed, where the configuration file is located (should you want to edit it), version information, and so on.

Using phpinfo()

Here’s how to use the phpinfo function:


Pretty simple. Navigate to your hosted PHP script, which contains the call to phpinfo(), and you will see a formatted page containing everything you would want to know about your PHP installation.

If you are looking to validate your PHP code – find out how to validate it from the command line in this article.

Using phpinfo() from the Command Line

phpinfo() can also be used from the command line:

php -r 'phpinfo();'

Above, the -r option is used when calling PHP from the command line to execute the quoted code and print it to the terminal, bypassing the need for a browser. This is useful if you want to quickly check your PHP configuration without creating a file and navigating to it in a web browser.

Optional Options

You can limit which information is output by phpinfo() by passing one of the following values:

INFO_GENERAL General information – Configuration line, php.ini location, build date, configured web server, operating system, etc.
INFO_CONFIGURATION Current Local and Master values for PHP directives/configuration values
INFO_MODULES Loaded modules and their settings
INFO_ENVIRONMENT Environment Variable information
INFO_VARIABLES Predefined variables
INFO_LICENSE PHP License information
INFO_ALL Shows everything (the default)

For example:


…Would print only the information on PHP modules.

Photo of author
I'm Brad, and I'm nearing 20 years of experience with Linux. I've worked in just about every IT role there is before taking the leap into software development. Currently, I'm building desktop and web-based solutions with NodeJS and PHP hosted on Linux infrastructure. Visit my blog or find me on Twitter to see what I'm up to.

Leave a Comment