What is the proper value type of the new value when using ini_set()?
On php.net the syntax looks like this:
string ini_set(string $varname, string $newvalue)
All parameters should be a string
. On the php.ini file all booleans shown as On
or Off
. The following solution should be the most proper solution:
ini_set('display_errors', 'On');
ini_set('display_errors', 'Off');
On the documentation of the configuration file you can find the following part:
Boolean values can be set to either:
true, on, yes or false, off, no, none
http://php.net/manual/en/configuration.file.php
On ini_get
the return value is a string. The documentation says:
A boolean ini value of off will be returned as an empty string or "0" while a boolean ini value of on will be returned as "1". The function can also return the literal string of INI value.
http://php.net/manual/en/function.ini-get.php
The return value of ini_get
and the value for ini_set
have to be a string!
Referring : http://php.net/manual/en/function.ini-set.php
string ini_set ( string $varname , string $newvalue )
So you have to use a string for newValue
eg:
<?php
echo ini_get('display_errors');
if (!ini_get('display_errors')) {
ini_set('display_errors', '1');
}
echo ini_get('display_errors');
?>