phpinfo() - php 选项信息函数
phpinfo()
(PHP 4, PHP 5, PHP 7)
输出关于 PHP 配置的信息
说明
phpinfo([int $what= INFO_ALL]): bool输出 PHP 当前状态的大量信息,包含了 PHP 编译选项、启用的扩展、PHP 版本、服务器信息和环境变量(如果编译为一个模块的话)、PHP环境变量、操作系统版本信息、path 变量、配置选项的本地值和主值、HTTP 头和PHP授权信息(License)。
因为每个系统安装得有所不同,phpinfo()常用于在系统上检查配置设置和预定义变量。
phpinfo()同时是个很有价值的、包含所有 EGPCS(Environment, GET, POST, Cookie, Server)数据的调试工具。
参数
$what可以用以下的一个或多个constants用位运算传递给可选的$what参数来定制输出的信息。该参数可以把常量相加或者用or操作符按位运算。
Name (constant) | Value | Description |
---|---|---|
INFO_GENERAL | 1 | 配置的命令行、php.ini的文件位置、建立的时间、Web 服务器、系统及更多其他信息。 |
INFO_CREDITS | 2 | PHP 贡献者名单。参加phpcredits()。 |
INFO_CONFIGURATION | 4 | 当前PHP指令的本地值和主值。参见ini_get()。 |
INFO_MODULES | 8 | 已加载的模块和模块相应的设置。参见get_loaded_extensions()。 |
INFO_ENVIRONMENT | 16 | 环境变量信息也可以用$_ENV获取。 |
INFO_VARIABLES | 32 | 显示所有来自 EGPCS (Environment, GET, POST, Cookie, Server)的预定义变量。 |
INFO_LICENSE | 64 | PHP许可证信息。参见» license FAQ。 |
INFO_ALL | -1 | 显示以上所有信息。 |
返回值
成功时返回TRUE
,或者在失败时返回FALSE
。
更新日志
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 | 增加了“已加载的配置文件”信息,之前只存在“配置文件路径(php.ini)"。 |
范例
Example #1phpinfo()范例
注释
Note:在 PHP 5.5 之前版本,当expose_php设置为off可以禁用一部分信息。这包括了 PHP 和 Zend 的 logo,以及贡献者名单。Note:
在命令行(CLI)模式下phpinfo()仅会输出纯文本,而不是HTML。
参见
phpversion()
获取当前的PHP版本phpcredits()
打印 PHP 贡献者名单php_logo_guid()
获取 logo 的 guidini_get()
获取一个配置选项的值ini_set()
为一个配置选项设置值get_loaded_extensions()
返回所有编译并加载模块名的 array- Predefined Variables
After reading and trying various functions, I couldn't find one that correctly parses all the configurations, strips any left-over html tag and converts special characters into UTF8 (e.g. ' into '), so I created my own by improving on the existing ones: function phpinfo2array() { $entitiesToUtf8 = function($input) { // http://php.net/manual/en/function.html-entity-decode.php#104617 return preg_replace_callback("/([0-9]+;)/", function($m) { return mb_convert_encoding($m[1], "UTF-8", "HTML-ENTITIES"); }, $input); }; $plainText = function($input) use ($entitiesToUtf8) { return trim(html_entity_decode($entitiesToUtf8(strip_tags($input)))); }; $titlePlainText = function($input) use ($plainText) { return '# '.$plainText($input); }; ob_start(); phpinfo(-1); $phpinfo = array('phpinfo' => array()); // Strip everything after theConfiguration
tag (other h1's) if (!preg_match('#(.*]*>\s*Configuration.*)
鹏仔微信 15129739599 鹏仔QQ344225443 鹏仔前端 pjxi.com 共享博客 sharedbk.com
图片声明:本站部分配图来自网络。本站只作为美观性配图使用,无任何非法侵犯第三方意图,一切解释权归图片著作权方,本站不承担任何责任。如有恶意碰瓷者,必当奉陪到底严惩不贷!