[PHP] Error takeover class

Source: Internet
Author: User
Tags what php

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.