如何从php程序获取phpinfo()变量? [英] How to get phpinfo() variables from php programatically?
问题描述
我试图得到一个可靠的(一致的请求)PHP中的隐藏常量列表(因为,客户端不知道它在大多数情况下没有黑客)。
I am attempting to get a list of dependable(consistent across requests) list of "hidden" constants in PHP(as in, the client-side won't know about it in most cases without hacking).
我感兴趣的部分如下:
-
./ configure
选项。 - 我也喜欢第一个
System
在phpinfo。 - 已载入的PHP模组(如Apache一节所示)
- PHP的建立日期。
- 已注册的PHP流
- 已注册的流套接字传输
- 注册的流过滤器
./configure
options.- I would also like the very first
System
value in phpinfo. - The loaded PHP modules(as shown in the Apache section)
- The build date of PHP.
- Registered PHP streams
- Registered stream socket transports
- Registered stream filters
如何获取phpinfo的一部分或获取这些值作为一个常规字符串?注意,如果是否包含标记没有关系,但我不想解析phpinfo,因为只是看起来真的慢,肯定有一个更好的方法。
How can I get either just a portion of the phpinfo or get these values as a regular string? Note that it doesn't matter if there if markup included, but I don't want to parse the phpinfo as that just seems really slow and surely there is a better way..
推荐答案
这里:
-
ini_get_all code>或
get_loaded_extensions()
是我能找到的最接近的。 -
php_uname()
-
apache_get_modules()
-
phpversion()
是我可以找到的最接近的。 -
stream_get_wrappers / code>
-
stream_get_transports()
-
stream_get_filters()
ini_get_all()
orget_loaded_extensions()
were the closest I could findphp_uname()
apache_get_modules()
phpversion()
was the closest I could findstream_get_wrappers()
stream_get_transports()
stream_get_filters()
另请参见 get_defined_constants()
和其他。
正如Chacha102所提到的,你也可以使用输出控制函数并解析 phpinfo()
:
As Chacha102 mentioned you can also use output control functions and parse the phpinfo()
:
ob_start();
phpinfo();
$variable = ob_get_contents();
ob_get_clean();
由于使用 ob_get_clean()
它不会混乱你可能使用的其他输出缓冲级别。
Due to the use of ob_get_clean()
it won't mess up other output buffering levels you may be using.
这篇关于如何从php程序获取phpinfo()变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!