To get a wrong takeover class:
<?PHP//----------------------------------//leephp Error takeover class//2017-07-06//pengchonglee//------------------------------- ---//error_reporting-setting what PHP errors should be reported error_reporting(0); classerro{ Public function__construct () {$this-Iserr (); } Public functionIserr () {//set_exception_handler-Setting user-defined exception handling functions Set_exception_handler([$this, ' ex ']); //set_error_handler-Setting user-defined error handling functions Set_error_handler([$this, ' Err ']); //register_shutdown_function-Register a function that will execute when PHP is aborted register_shutdown_function( [$this, ' Last_error ' ]); } //Abnormal takeover Public functionEx$ex) { //Get error exception information $message=$ex-GetMessage (); //Get error Exception code $code=$ex-GetCode (); //Get error Exception file $file=$ex-GetFile (); //get error Exception file line Count $line=$ex-GetLine (); } //wrong takeover Public functionErr$code,$message,$file,$line ) { //Record Log $this->errlog ($code,$message,$file,$line ); } //get last error before script ends Public functionLast_error () {//error_get_last-Get the last error that occurred $last=Error_get_last (); $this->errlog ($last[' type '],$last[' Message '],$last[' File '],$last[' Line '] ); } //error messages are collected and logged (parameters are transferred in different order, parameters are not the same) Public functionErrLog ($code,$message,$file,$line ) { //splicing error message $errstr=Date(' y-m-d h:i:s '). " \ r \ n "; $errstr. = ' Error level: '.$code." \ r \ n "; $errstr. = ' Error message: '.$message." \ r \ n "; $errstr. = ' Error file: '.$file." \ r \ n "; $errstr. = ' ERROR line number: '.$line." \ r \ n "; $errstr. = "\ r \ n"; //error_log-send error message to a place Error_log($errstr, 3,__dir__. ' /error.log '); }}
[PHP] Error takeover class