Common tips for error handling in PHP

Source: Internet
Author: User
This article mainly introduces PHP for error handling of the common skills, interested in the reference of friends, I hope to be helpful to everyone.

This article describes how PHP obtains error information, as follows:

function Error_reg () {$ar =array (  e_error = ' error ',  e_warning = ' WARNING ',  e_parse = ' prase ',  e_notice = ' NOTICE '); Register_shutdown_function (function () use ($ar) {  $ers =error_get_last ();  if ($ers [' type ']!=8 && $ers [' type ']) {   $er = $ar [$ers [' type ']]. $ers [' type ']. ': '. ' '. $ers [' message ']. ' = '. $ers [' file ']. ' Line: ' $ers [' line ']. ' '. Date (' y-m-d h:i:s '). " \ n ";   Error_log ($er, 3, '/tmp/php_error.log ');  } }); Set_error_handler (function ($a, $b, $c, $d) use ($ar) {  if ($a!=8 && $a) {   $er = $ar [$a]. $a. ': ' $b. ' = ' . $c. ' line: '. $d. '. Date (' y-m-d h:i:s '). " \ n ";   Error_log ($er, 3, '/tmp/php_error.log ');  } },e_all ^ e_notice);}

Summary : The above is the entire content of this article, I hope to be able to help you learn.

Related recommendations:

Implement video capture in PHP

Implement video capture in PHP

Php+ajax real-time input automatic search matching method

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.