It is imperative that phpinfo
is only used in a development environment. Never release code containing phpinfo
into a production environment
Having said that, it can be a useful tool in understanding the PHP environment (OS, configuration, versions, paths, modules) in which you are working, especially when chasing a bug. It is a simple built in function:
phpinfo();
It has one parameter $what
that allows the output to be customized. The default is INFO_ALL
, causing it to display all information and is commonly used during development to see the current state of PHP.
You can pass the parameter INFO_*
constants, combined with bitwise operators to see a customized list.
You can run it in the browser for a nicely formatted detailed look. It also works in PHP CLI, where you can pipe it into less
for easier view.
phpinfo(INFO_CONFIGURATION | INFO_ENVIRONMENT | INFO_VARIABLES);
This will display a list of PHP directives (ini_get
), environment ($_ENV
) and predefined variables.