Skip to content

Feature Request: new phpinfo_array() function #16560

Closed
@bkdotcom

Description

@bkdotcom

Description

phpinfo() contains a fair amount of information that is only obtainable via phpinfo()

phpinfo() outputs as either plain-text or html depending on if called via CLI or web process

To obtain a value, one must wrap phpinfo in ob_start() and then parse the text or html that it returns, or extract the specific desired value(s)

A new phpinfo_array() function that returns the "raw" information would be helpful

return

array(
    INFO_GENERAL => array(
        'PHP Version' => '8.5.0-dev',
        'System' => string,
        'Build Date' => string,
        ...
        //  this license info is output as a "keyless" value as text/html... assigned to "info" here
        'info' => 'This program makes use of the Zend Scripting Language Engine:.... ',
    ),
    INFO_CREDITS => array(
        'PHP Group' => string,
        'Language Design & Concept' => string,
        'PHP Authors' => array(
            'Zend Scripting Language Engine' => string,
            'Extension Module API' => string,
            ...
        ),
        ...
    ),
    INFO_CONFIGURATION => array(
        'allow_url_fopen' => ['On', 'On'],
        ...
    ),
    INFO_MODULES => array(
        //    all module keys lowercase for consistancy
        'bcmath' => array(
            'BCMath support' => enabled,
            'bcmath.scale' => ['0', '0'],
            ...
         ),
        ...
        'phar' => array(
            'Phar: PHP Archive support' => 'enabled',
            ...
           // phar, xdebug, and others output "keyless" "information/license/disclaimer".   I've assigned to "info" here
            'info' => 'Phar based on pear/PHP_Archive, original concept by Davey Shafik. Phar fully realized by Gregory Beaver and Marcus Boerger. Portions of tar implementation Copyright (c) 2003-2009 Tim Kientzle.'
            ...
            'phar.cache_list' => [null, null], //   html and text output 'no value'
            ...
        ),
        'additional modules' => [], // list of lowercase strings 
    ),
    INFO_ENVIRONMENT => array(
        'TERM_PROGRAM' => string,
        ...
    ),
    INFO_VARIABLES => array(
         //   the values...    not the flattened /+print_r output that text/html gives
         '$_COOKIE' => array(),
         '$_SERVER' => array(),
         ....
    ),
    INFO_LICENSE => string,
)

If a single category flag is passed to phpinfo_array(), the topmost category level keys could be omitted

phpinfo_array(INFO_GENERAL)

return

array(
    'PHP Version' => '8.5.0-dev',
    'System' => string,
    'Build Date' => string,
    ...
),

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions