如何禁用部分代码的错误/异常处理程序?

I'm using PHP version 5.3.19 and I have the following code :

set_exception_handler(array($this->main_model,'nothing'));
set_error_handler(array($this->main_model,'nothing'));
error_reporting(0);
foreach ($data as $row){
...
}
restore_error_handler();

Now i just tried hacking with the nothing there, it's a function doing nothing because i tried setting them as null but that didn't changed, and this doesn't change it too.

I've also tried wrapping in try catch but it stills handles the error.

I can't disable the errors completly as im using them with a custom error handler, what i want is to disable the foreach loop for errors, i've also called the function with @ but since i used custom error handler it no longer worked.

I've read here that when using custom handler php ignores error_reporting.

How can i get the foreach to not handle errors no matter what?

Neither set_error_handler() nor set_exception_handler() enable us to log fatal errors such E_ERROR, E_PARSE and E_CORE_ERROR.

The solution to the problem is register_shutdown_function()

This function lets you register a callback function that will be run when PHP is shutting down, even when it is forced to shut down due to entering an unstable state.

Here is a Custom Class which enables you to Register or Unregister a ShutDown Function.

class UnregisterableCallback{

    // Store the Callback for Later
    private $callback;

    // Check if the argument is callable, if so store it
    public function __construct($callback)
    {
        if(is_callable($callback))
        {
            $this->callback = $callback;
        }
        else
        {
            throw new InvalidArgumentException("Not a Callback");
        }
    }

    // Check if the argument has been unregistered, if not call it
    public function call()
    {
        if($this->callback == false)
            return false;

        $callback = $this->callback;
        $callback(); // weird PHP bug
    }

    // Unregister the callback
    public function unregister()
    {
        $this->callback = false;
    }
}

You can use this Class logic along with your code.