ini_set()
ini_set() — Sets 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.
What it does
Sets the value of the given configuration option. The configuration option will keep this new value during the script's execution, and will be restored at the script's ending.
Signature
ini_set(string $option, string|int|float|bool|null $value): string|false
Parameters
| Parameter | Type | What it takes |
|---|---|---|
| $option | string | Not all the available options can be changed using ini_set(). There is a list of all available options in the appendix. |
| $value | string|int|float|bool|null | The new value for the option. |
Return value
Returns the old value on success, false on failure.
Example
A runnable snippet:
echo ini_get('display_errors'); if (!ini_get('display_errors')) { ini_set('display_errors', '1'); } echo ini_get('display_errors');
Changelog
| Version | Change |
|---|---|
| 8.1.0 | value now accepts any scalar type (including null). Previously, only string values were accepted. |
See also
get_cfg_var(), ini_get(), ini_get_all(), ini_restore()
All PHP 8.5 built-in functions
Reference card built from the PHP manual page ini_set() (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.