In order to block changing of settings via ini_set()
you need to overwrite or completely disable it.
Disable ini_set
Put ini_set
into the list of disabled functions in your php.ini
:
disable_functions=ini_set
This has the disadvantage, that an error will be logged for every call to ini_set()
.
Overwrite ini_set
There are at least 2 ways to overwrite a function:
There is overwrite_function()
(Docs) which may or may not be installed in your system. The following snippet will silently disable ini_set()
:
override_function('ini_set', '$a,$b', 'return true;');
And you can use namespaces to overwrite the behaviour:
<?php
namespace MyNamespace {
function ini_set($key, $value)
{
return true;
}
ini_set('display_error', 'all');
In the above snippet, the function ini_set
will resolve to MyNamespace\ini_set
which overwrites the behaviour.
Source and Explanation for this method: https://stackoverflow.com/a/12128017/1392490