Encodera

Thanks for reading!

Donate to the site — we work hard for you.

PHP reference

ini_set

Changes a PHP setting for the duration of the program.

Syntax

ini_set(string $option, string|int|float|bool|null $value): string|false

Parameters

ParameterTypeDescription
$optionstringThe setting name.
$valuestring|int|float|bool|nullThe 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
4

Notes

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

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.

Thanks for reading!

Donate to the site — we work hard for you.