RCRAMER.COM
Clever website slogan
Home > Tech > PHP

phpinfo()

Outputs a large amount of information about the current state of PHP. 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.

Because every system is setup differently, phpinfo() is commonly used to check configuration settings and for available predefined variables on a given system.

phpinfo() is also a valuable debugging tool as it contains all EGPCS (Environment, GET, POST, Cookie, Server) data.

<?php phpinfo(); ?>
Name (constant)ValueDescription
INFO_GENERAL 1 The configuration line, php.ini location, build date, Web Server, System and more.
INFO_CREDITS 2 PHP Credits. See also phpcredits().
INFO_CONFIGURATION 4 Current Local and Master values for PHP directives. See also ini_get().
INFO_MODULES 8 Loaded modules and their respective settings. See also get_loaded_extensions().
INFO_ENVIRONMENT 16 Environment Variable information that's also available in $_ENV.
INFO_VARIABLES 32 Shows all predefined variables from EGPCS (Environment, GET, POST, Cookie, Server).
INFO_LICENSE 64 PHP License information.
INFO_ALL -1 Shows all of the above.

the following is an example of phpinfo(INFO_VARIABLES) ouput:

VariableValue
_REQUEST["name"]no value
_POST["name"]no value
_SERVER["HTTP_HOST"]192.168.75.130
_SERVER["HTTP_USER_AGENT"] Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12
_SERVER["HTTP_ACCEPT"] text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
_SERVER["HTTP_ACCEPT_LANGUAGE"]en-us,en;q=0.5
_SERVER["HTTP_ACCEPT_ENCODING"]gzip,deflate
_SERVER["HTTP_ACCEPT_CHARSET"]ISO-8859-1,utf-8;q=0.7,*;q=0.7
_SERVER["HTTP_KEEP_ALIVE"]115
_SERVER["HTTP_CONNECTION"]keep-alive
_SERVER["HTTP_REFERER"]http://192.168.75.130/phpinfo.php
_SERVER["CONTENT_TYPE"]application/x-www-form-urlencoded
_SERVER["CONTENT_LENGTH"]5
_SERVER["PATH"]/usr/local/bin:/usr/bin:/bin
_SERVER["SERVER_SIGNATURE"] <address>Apache/2.2.14 (Ubuntu) Server at 192.168.75.130 Port 80</address>
_SERVER["SERVER_SOFTWARE"]Apache/2.2.14 (Ubuntu)
_SERVER["SERVER_NAME"]192.168.75.130
_SERVER["SERVER_ADDR"]192.168.75.130
_SERVER["SERVER_PORT"]80
_SERVER["REMOTE_ADDR"]192.168.75.1
_SERVER["DOCUMENT_ROOT"]/var/www
_SERVER["SERVER_ADMIN"]webmaster@localhost
_SERVER["SCRIPT_FILENAME"]/var/www/phpinfo.php
_SERVER["REMOTE_PORT"]61799
_SERVER["GATEWAY_INTERFACE"]CGI/1.1
_SERVER["SERVER_PROTOCOL"]HTTP/1.1
_SERVER["REQUEST_METHOD"]POST
_SERVER["QUERY_STRING"]no value
_SERVER["REQUEST_URI"]/phpinfo.php
_SERVER["SCRIPT_NAME"]/phpinfo.php
_SERVER["PHP_SELF"]/phpinfo.php
_SERVER["REQUEST_TIME"]1290192094