setIniIfExists.php
Table of Contents
Functions
- setIniIfExists() : bool
- Set a PHP ini directive from a scalar or from a config array if the value exists and is not empty.
Functions
setIniIfExists()
Set a PHP ini directive from a scalar or from a config array if the value exists and is not empty.
setIniIfExists(string $key[, array<string|int, mixed>|string|int|float|bool|null $init = [] ]) : bool
Behavior:
- If $init is an array, this function looks up $init[$key]; otherwise it treats $init as the value.
- The value is cast to string and trimmed; empty strings are ignored.
- ini_set() is invoked only if the function exists and a non-empty value is provided.
- Returns true when ini_set() is called, false otherwise.
Notes:
- Most ini values are strings; booleans are commonly expressed as "1"/"0". Passing true/false will be cast to "1"/"" by PHP.
- Use ini_get($key) to read back the effective value after setting.
Parameters
- $key : string
-
The ini key (e.g. 'display_errors', 'memory_limit').
- $init : array<string|int, mixed>|string|int|float|bool|null = []
-
A config array (looked up by $key) or a direct scalar value.
Tags
Return values
bool —True if ini_set() was called, false otherwise.