如何以编程方式从php获取phpinfo()变量? [英] How to get phpinfo() variables from php programmatically?

查看:111
本文介绍了如何以编程方式从php获取phpinfo()变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取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).

我感兴趣的一些东西如下:

Some of the things I am interested in is the following:

  1. ./configure选项.
  2. 我还想要phpinfo中的第一个System值.
  3. 已加载的PHP模块(如Apache部分所示)
  4. PHP的构建日期.
  5. 注册的PHP流
  6. 已注册的流套接字传输
  7. 已注册的流过滤器
  1. ./configure options.
  2. I would also like the very first System value in phpinfo.
  3. The loaded PHP modules(as shown in the Apache section)
  4. The build date of PHP.
  5. Registered PHP streams
  6. Registered stream socket transports
  7. 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..

推荐答案

在这里:

  1. ini_get_all()get_loaded_extensions() 是我能找到的最接近的
  2. php_uname()
  3. apache_get_modules()
  4. phpversion() 是我能找到的最接近的
  5. stream_get_wrappers()
  6. stream_get_transports()
  7. stream_get_filters()
  1. ini_get_all() or get_loaded_extensions() were the closest I could find
  2. php_uname()
  3. apache_get_modules()
  4. phpversion() was the closest I could find
  5. stream_get_wrappers()
  6. stream_get_transports()
  7. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆