ini_get()

ini_get() — Gets the value of a configuration option.

Built-in function of PHP 8.5. The manual lists it as available in PHP 4, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.

Signature

ini_get(string $option): string|false

Parameters

ParameterTypeWhat it takes
$optionstringThe configuration option name.

Return value

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

Example

A runnable snippet:

/* 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'));

Output:

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

See also

get_cfg_var(), ini_get_all(), ini_parse_quantity(), ini_restore(), ini_set()

All PHP 8.5 built-in functions

Reference card built from the PHP manual page ini_get() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.