1

Hi ive made a custom redirection function when there's a fatal error on a script :

This is called on a prepend script included before all pages :

register_shutdown_function("shutdownHandler");
function shutdownHandler() 
{
    $lasterror = error_get_last();
    switch ($lasterror['type'])
        {
            case E_ERROR:
            case E_CORE_ERROR:
            case E_COMPILE_ERROR:
            case E_USER_ERROR:
            case E_RECOVERABLE_ERROR:
            case E_CORE_WARNING:
            case E_COMPILE_WARNING:
            case E_PARSE:
                $error = "[SHUTDOWN] lvl:" . $lasterror['type'] . " | msg:" . $lasterror['message'] . " | file:" . $lasterror['file'] . " | ln:" . $lasterror['line'];
                writeError($error, "fatal");
                header("location:maintenance.php");
        }
}

But the function is NOT called, any ideas ?

3
  • Please show a complete example, including how that function is registered.
    – deceze
    Feb 18, 2014 at 18:55
  • Where does shutdownHandler gets executed?
    – berentrom
    Feb 18, 2014 at 18:55
  • executed in a script included before all scripts
    – SoCkEt7
    Feb 18, 2014 at 18:59

2 Answers 2

0

I solved this issue !

By adding my errorsHandler.php script in my php.ini file under the directive :

auto-prepend-file = [path/to/file]

Hope it will help ;)

0

You can also disable PHP to display errors, which could cause for your shutdownHandler function not to be called.

You can do this in php.ini file or in your PHP file:

ini_set('display_errors', false);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.