Show PHP configuration options for a selected extensionShow PHP configuration options for a selected extension

Posted May 25th, 2009 in PHP

Last week I posted about PHP's ini_get_all function to show PHP's configuration options and in this post show how to get just the config for a particular extension.

PHP has a large number of extensions available, including for MySQL (with both MySQL and MySQLi libraries), the GD image library, session handling, zlib and so on. Many of theses extensions have a set of configuration options which can be read using the ini_get or get_cfg_var functions.

Using the ini_get_all function you can either get all the configuration settings or just those for a selected extension by passing the extension name in as the first parameter. The following example illustrates this getting the config for the mysqli extension:

$options = ini_get_all('mysqli');

Then doing print_r($options) would show something like this:

Array
(
    [mysqli.default_host] => Array
        (
            [global_value] =>
            [local_value] =>
            [access] => 7
        )

    [mysqli.default_port] => Array
        (
            [global_value] => 3306
            [local_value] => 3306
            [access] => 7
        )

    [mysqli.default_pw] => Array
        (
            [global_value] =>
            [local_value] =>
            [access] => 7
        )

    [mysqli.default_socket] => Array
        (
            [global_value] =>
            [local_value] =>
            [access] => 7
        )

    [mysqli.default_user] => Array
        (
            [global_value] =>
            [local_value] =>
            [access] => 7
        )

    [mysqli.max_links] => Array
        (
            [global_value] => -1
            [local_value] => -1
            [access] => 4
        )

    [mysqli.reconnect] => Array
        (
            [global_value] =>
            [local_value] =>
            [access] => 4
        )

)

Global value and local value

The global_value contains the value that is set in the php.ini file. The local_value contains the modified value (if modified) in the <virtualhost>, .htaccess file or ini_set().

Access

Access uses the following PHP constants:

PHP_INI_USER 1 Entry can be set in user scripts
PHP_INI_PERDIR 2 Entry can be set in php.ini, .htaccess or httpd.conf
PHP_INI_SYSTEM 4 Entry can be set in php.ini or httpd.conf
PHP_INI_ALL 7 Entry can be set anywhere

The value can also be 6 i.e. PHP_INI_PERDIR + PHP_INI_SYSTEM.

Related posts:

Comments

blog comments powered by Disqus