PHP.nl

ini_get

ini_get

Gets the value of a configuration option

 **ini_get** string $option

Returns the value of the configuration option on success.

optionThe configuration option name.

Returns the value of the configuration option as a string on success, or an empty string for values. Returns false if the configuration option doesn't exist. null

Voorbeeld: A few examples

<?php

/*
Our php.ini contains the following settings:

display_errors = On
opcache.enable_cli = Off
post_max_size = 8M
*/

echo 'display_errors = ' . ini_get('display_errors') . "\n";
echo 'opcache.enable_cli = ' . (int) ini_get('opcache.enable_cli') . "\n";
echo 'post_max_size = ' . ini_get('post_max_size') . "\n";
echo 'post_max_size + 1 = ' . (rtrim(ini_get('post_max_size'), 'KMG') + 1) . "\n";
echo 'post_max_size in bytes = ' . ini_parse_quantity(ini_get('post_max_size'));

?>
display_errors = 1
opcache.enable_cli = 0
post_max_size = 8M
post_max_size+1 = 9
post_max_size in bytes = 8388608

Opmerking: > ### When querying boolean values

A boolean ini value of  will be returned as an
empty string or "0" while a boolean ini value of  will
be returned as "1".
The function can also return the literal string of INI value.

off``on

Opmerking: > ### When querying memory size values

Many ini memory size values, such as
, are
stored in the php.ini file in shorthand notation.
 will return the exact string stored in the
php.ini file and  its 
equivalent.  Attempting normal arithmetic functions on these values
will not have otherwise expected results.  The
 function can be used to convert
the shorthand notation into bytes.

upload_max_filesizeini_getNOTint``ini_parse_quantity

Opmerking: > can't read "array" ini options such as , and returns false in this case. ini_get``pdo.dsn.*

get_cfg_var``ini_get_all``ini_parse_quantity``ini_restore``ini_set