Detailed PHP error Log acquisition method, detailed PHP log get _php Tutorial

Source: Internet
Author: User
Tags php error php error log

Detailed PHP error Log acquisition method, detailed PHP log acquisition


In PHP error log get a lot of ways, below I give you a brief introduction of how to solve this kind of problem, the following through the code to show you, hope to help everyone.

<?phperror_reporting (0); Register_shutdown_function ($err = ' My_error_handler ') OR Set_error_handler ($err, E_ALL); Register two functions at the same time.//function parameter Error $original = unserialize (Array (423142,2134234));//Not 0 except Echo 1/0;//does not exist array index echo $_get[' AA '];//does not exist The constant php_e;//does not exist for the variable echo $var;//function parameter error strlen (Array (2434));//function parameter error MD5 (Array (1));//user custom error Trigger_error (' Safdds ', e_ User_notice)///non-existent function PHP interrupt//TES ();//non-existent method php Interrupt $ts = new AFSD (); function My_error_handler ($errno =0, $errstr =0, $ERRF   Ile=0, $errline =0) {if ($errno && $errfile) {if (true) {$earr = array ();   $earr [' type '] = $errno;   $earr [' message '] = $ERRSTR;   $earr [' file '] = $errfile;  $earr [' line '] = $errline; }}else{$earr = Error_get_last ();} Echo '
'; Print_r ($earr); return array ();}

For PHP errors, we must understand clearly, types, when the trigger, the return value is what.

If you do not distinguish between the types of warnings, errors, suggestions, hints, etc., then we can understand that there are two types of PHP errors:

One is to force the interrupt program error. such as error, method does not exist, etc. Insufficient memory, timed out

A non-disruptive error. such as warnings, prompting these

Where getting an interrupt program error requires the use of the Register_shutdown_function function, registering a memory function, and then getting the error message inside, this method can only get to the first error line, such as multiple non-existent functions, it can only get to the first error. This is actually good, you fix one, it moves to the next.

Non-disruptive error, if used: register_shutdown_function, it will become extremely difficult to operate, only to get the first hint or warning, then we need to set_error_handler, every time the touch of error level constants, the error function is called once, and you can get the error log inside. However, this function will take the Error_get_last function, so you will find that Error_get_last returns NULL, all passed by the parameter.

Two functions together, you can get to the program's 99% error, which for the PHP program, is the snow to send a lighter.

Try running the example above.

Through the combination of code and text to get the error log in PHP collation, I hope you will encounter such problems in the future work to help.

http://www.bkjia.com/PHPjc/1035667.html www.bkjia.com true http://www.bkjia.com/PHPjc/1035667.html techarticle detailed PHP error log to get a detailed explanation of PHP log get in PHP error log gets a number of ways, below I give you a brief introduction of how to solve this kind of problem, the following ...

  • 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.