Home > Article > Backend Development > How does PHP use phpinfo() to obtain PHP configuration information? (code example)
PHP provides us with a built-in function phpinfo(), which can provide detailed information about the PHP version and PHP configuration installed in the system. So how to use phpinfo() function? The following article will show you how to use the phpinfo() function. I hope it will be helpful to you.
Recommended related articles: " Detailed explanation of the use of php.ini and phpinfo()"
Recommended video tutorials: "PHP video tutorial"
phpinfo() function
The phpinfo() function will output information about PHP configuration.
Basic syntax:
phpinfo ([ int $what = INFO_ALL ] )
Parameters:
$what is an omitted parameter, but $what is omitted , all configuration information will be output.
It can have the following values:
● INFO_GENERAL: Information overview, used to display configuration lines, php.ini location, build date, web server, system, etc.
● INFO_CREDITS: used to display PHP Credits.
● INFO_CONFIGURATION: Information configuration, used to display the current value, local value and main value of PHP instructions.
● INFO_MODULES: Information module, used to display loaded modules and their respective settings.
● INFO_ENVIRONMENT: Information environment, used to display environment variable information.
● INFO_VARIABLES: Information variables, which displays all predefined variables from EGPCS (environment, GET, POST, Cookie, server).
● INFO_LICENSE: Information license, used to display PHP license information.
● INFO_ALL: All information, display all the above information.
Return type: The phpinfo() function returns a Boolean value. That is, it returns true on success and false on failure.
How to display PHP configuration information?
1. Complete configuration information
To display complete information about PHP version, configuration, environment details, etc., the phpinfo() function should be executed as follows:
<?php phpinfo(); ?>
Output:
Note: When using CLI mode, phpinfo() outputs plain text instead of HTML.
2. Display specific information
If you want to display specific configuration information in PHP, just add the $what parameter:
<?php //PHP许可证信息 phpinfo(INFO_LICENSE); ?>
Output:
The above is the entire content of this article, I hope it will be helpful to everyone's study. For more exciting content, you can pay attention to the relevant tutorial columns of the PHP Chinese website! ! !
The above is the detailed content of How does PHP use phpinfo() to obtain PHP configuration information? (code example). For more information, please follow other related articles on the PHP Chinese website!