• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
The Electric Toolbox Blog

The Electric Toolbox Blog

Linux, Apache, Nginx, MySQL, Javascript and PHP articles

  • Applications
  • FCKEditor
  • Apache
  • Windows
  • Contact Us
Home / PHP’s ini_get_all function

PHP’s ini_get_all function

PHP has a large number of configuration options which can be set in the php.ini file, Apache virtualhost settings, .htaccess and with the ini_set function. This post looks at the ini_get_all function which returns an array containing all the possible configuration options, what their global and local script value are and where they can be modified.

Sample code:

$options = ini_get_all();
print_r($options);

Example output:

Array
(
    [allow_call_time_pass_reference] => Array
        (
            [global_value] => 1
            [local_value] => 1
            [access] => 6
        )

    [allow_url_fopen] => Array
        (
            [global_value] => 1
            [local_value] => 1
            [access] => 4
        )

    ... more configuration options ...

    [zlib.output_handler] => Array
        (
            [global_value] => 
            [local_value] => 
            [access] => 7
        )

)

Accessing the values

The associative array that is returned contains a key name which is the configuration option name with a sub-array containing the keys ‘global_value’, ‘local_value’ and ‘access’. If you wanted to find out the local value for ‘allow_url_fopen’ for example, you could do something like this:

if($options['allow_url_fopen']['local_value'] == 1) {
    // do something
}
else {
    // do something else
}

Of course, you could also do the above using ini_get like this if all you needed was the local value:

if(ini_get('allow_url_fopen') == 1) {
    // do something
}
else {
    // do something else
}

Global value vs 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.

Check Out These Related posts:

  1. Get unique array values with PHP
  2. Set PHP configuration options with an Apache .htaccess file
  3. Logging errors with PHP
  4. Changing exim4 settings with Debian 5 Lenny

Filed Under: PHP

Primary Sidebar

Categories

  • Apache
  • Applications
  • Article
  • Case Studies
  • Email Servers
  • FCKEditor
  • HTML And CSS
  • Javascript
  • Linux/Unix/BSD
  • Microsoft SQL Server
  • Miscellaneous Postings
  • MySql
  • Networking
  • Nginx Web Server
  • Offsite Articles
  • OSX
  • PHP
  • Quick Tips
  • RFC – Request for Comments
  • SilverStripe
  • VMWare
  • VPN
  • Windows
  • WordPress

Recent Posts

  • Vim Show Line Numbers
  • Add User To Group Linux
  • Chmod 777 Tutorial
  • How to Copy Directory Linux
  • Linux create user

Copyright © 2021. ElectricToolBox. All Rights Reserved.

  • Contact Us
  • Copyright Info
  • Privacy Policy
  • Sitemap