How to get phpinfo() variables from php programmatically?

前端 未结 3 2047
轻奢々
轻奢々 2021-02-07 08:04

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 hac

相关标签:
3条回答
  • 2021-02-07 08:15

    Maybe I am late a bit, but basically if you call a shell script problematically to the php.exe

    php -i
    

    then you can parse all the information required

    0 讨论(0)
  • 2021-02-07 08:23

    Most of the stuff available from phpinfo() can be found in constants. Try looking through:

    print_r(get_defined_constants());
    

    Or the functions on this page: http://us.php.net/manual/en/ref.info.php. There are tons of functions to get information about specific extensions.

    The following functions might be worth looking at:

    ini_get() http://us.php.net/manual/en/function.ini-get.php
    getenv() http://us.php.net/manual/en/function.getenv.php
    get_cfg_var() http://us.php.net/manual/en/function.get-cfg-var.php

    0 讨论(0)
  • 2021-02-07 08:30

    Here you go:

    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()

    See also get_defined_constants() and some more.


    As Chacha102 mentioned you can also use output control functions and parse the phpinfo():

    ob_start();
    phpinfo();
    $variable = ob_get_contents();
    ob_get_clean();
    

    Due to the use of ob_get_clean() it won't mess up other output buffering levels you may be using.

    0 讨论(0)
提交回复
热议问题