ini_set
Changes a PHP setting for the duration of the program.
Syntax
ini_set(string $option, string|int|float|bool|null $value): string|falseParameters
| Parameter | Type | Description |
|---|---|---|
| $option | string | The setting name. |
| $value | string|int|float|bool|null | The new value. |
Return value
string|falseThe previous value, or `false` on failure.
Examples
The precision of float output:
<?php
ini_set('precision', '4');
echo 1 / 3, "\n";
echo ini_get('precision');Output:
0.3333
4Notes
Common settings: display_errors, memory_limit, max_execution_time. The change lasts only until the end of the current request; permanent values go into php.ini.
See also
- error_reporting — Sets which errors PHP should report.
- getenv — Returns the value of an environment variable.
- date_default_timezone_set — Sets the time zone for every date function.
In the tutorial
- Configuration and environment — Where to keep the settings of a PHP project — a configuration file, environment variables, the .env file, different modes for development and the server.