Friday, December 14, 2012

php catching fatal errors


Source

register_shutdown_function('handleShutdown');

function handleShutdown() {
        $error = error_get_last();
        if($error !== NULL){
            $info = "[SHUTDOWN] file:".$error['file']." | ln:".$error['line']." | msg:".$error['message'] .PHP_EOL;
            yourPrintOrMailFunction($info);
        }
        else{
            yourPrintOrMailFunction("SHUTDOWN");
        }
    }

No comments:

Blog Archive