What is the use of phpinfo () in php?

View Discussion

Improve Article

Save Article

  • Read
  • Discuss
  • View Discussion

    Improve Article

    Save Article

    PHP provides us with a built-in function phpinfo() which gives us the details about the PHP version and PHP configuration of PHP installed in our system. To know about the Configurations and PHP version which is installed in your computer, a simple PHP script can be used. The script consists of a PHP function called “phpinfo()” which outputs information about PHP’s configuration. The phpinfo() function is also useful in the debugging process.
    This function generally outputs a large amount of information, such as:  

    1. Information about PHP compilation options and extensions.
    2. PHP version.
    3. Server information and environment (if compiled as a module).
    4. PHP environment.
    5. OS version information, paths, master and local values of configuration options.
    6. HTTP headers.
    7. PHP license.

    Syntax:  

    bool phpinfo ([ int $what = INFO_ALL ] )

    Parameters
    $what : It is an optional parameter which can be used to display specific information. 
    It can take the following values:  

    1. INFO_GENERAL:It is used to display the configuration line, php.ini location, build date, Web Server, System and more. 
       
    2. INFO_CREDITS:It is used to display PHP Credits. 
       
    3. INFO_CONFIGURATION: It is used to display current, local and Master values for PHP directives. 
       
    4. INFO_MODULES: It is used to display loaded modules and their respective settings. 
       
    5. INFO_ENVIRONMENT:It is used to display the environment variable information. 
       
    6. INFO_VARIABLES:It shows all predefined variables from EGPCS (Environment, GET, POST, Cookie, Server). 
       
    7. INFO_LICENSE:It is used to display PHP License information. 
       
    8. INFO_ALL:It shows all of the above information. 
       

    Return Type: The phpinfo() function return a boolean value. That is, it returns true on success and false on failure.
    Displaying Complete information: To display the complete information on the PHP version, configurations, environment details etc. the phpinfo() function should be executed in the following way: 

    php

    Output: 

    What is the use of phpinfo () in php?

    Note: phpinfo() outputs plain text instead of HTML when using the CLI mode.

    (PHP 4, PHP 5)

    phpinfoOutputs information about PHP's configuration

    Description

    bool phpinfo ([ int $what = INFO_ALL ] )

    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.

    Parameters

    what

    The output may be customized by passing one or more of the following constants bitwise values summed together in the optional what parameter. One can also combine the respective constants or bitwise values together with the or operator.

    phpinfo() options
    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. See also the » license FAQ.
    INFO_ALL -1 Shows all of the above.

    Return Values

    Returns TRUE on success or FALSE on failure.

    Changelog

    VersionDescription
    5.5.0 Logo GUIDs were replaced with data URIs, and so turning off expose_php now has no effect on the result of phpinfo(). Credits are also now embedded within the output itself instead of linked.
    5.2.2 The "Loaded Configuration File" information was added, when before only "Configuration File (php.ini) Path" existed.

    Examples

    Example #1 phpinfo() Example

    <?php// Show all information, defaults to INFO_ALL
    phpinfo();// Show just the module information.
    // phpinfo(8) yields identical results.
    phpinfo(INFO_MODULES);?>

    Notes

    Note:

    In versions of PHP before 5.5, parts of the information displayed are disabled when the expose_php configuration setting is set to off. This includes the PHP and Zend logos, and the credits.

    Note:

    phpinfo() outputs plain text instead of HTML when using the CLI mode.

    See Also

    • phpversion() - Gets the current PHP version
    • phpcredits() - Prints out the credits for PHP
    • php_logo_guid() - Gets the logo guid
    • ini_get() - Gets the value of a configuration option
    • ini_set() - Sets the value of a configuration option
    • get_loaded_extensions() - Returns an array with the names of all modules compiled and loaded
    • Predefined Variables

    How do I use Phpinfo in Wordpress?

    Go to your website's admin panel. Select Plugins > Add New. search for phpinfo() WP by Imran Hossain Sagor. Click Install Now button. Then simply click Active.

    Where can I find Phpinfo ()?

    Checking PHP Information by Creating a phpinfo File.
    Navigate to File Manager under the Files section in your hPanel..
    Once you're in public_html directory, click the New File button..
    Name your file phpinfo. ... .
    Scroll down and locate the new phpinfo file within the directory, then right-click to Edit..

    What is INI file in PHP?

    The php. ini file is the default configuration file for running applications that require PHP. It is used to control variables such as upload sizes, file timeouts, and resource limits. php. ini file is the configuration file.

    How do I write Phpinfo?

    To add a phpinfo() page to your site, follow the instructions below:.
    Log in to the Account Control Center (ACC).
    Navigate to your website files. ... .
    Create a new file..
    Name the file phpinfo.php..
    Enter the following code in the text field: ... .
    Click Create File..
    Now go visit your phpinfo.php file..