1

How do i ignore all ini_set("disply_error") error on function call done via code and use only settings configured in php.ini file?

When I did a grep for display_errors it shows a large list which cannot be changed by manually, so is there any way to use only php.ini settings?

rollstuhlfahrer
  • 3,988
  • 9
  • 25
  • 38
Muhammed Hafil
  • 165
  • 2
  • 9

1 Answers1

2

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

rollstuhlfahrer
  • 3,988
  • 9
  • 25
  • 38