Methods for error handling of PHP custom functions

Source: Internet
Author: User
Tags parse error
This article mainly introduces the use of PHP custom error handling, examples of PHP through the use of custom function error handling skills, the need for friends can refer to the following

The examples in this article describe the use of custom error handling in PHP. Specific as follows:

<?phperror_reporting (e_all); function ErrHandler ($errorno, $errorstr, $errorfile, $errorline) {$display = true;  $notify = false;  $halt _script = false;  $error _msg = "<br>the $errorno error is occurring at $errorline $errorfile <br>";   Switch ($errorno) {case E_user_notice:case e_notice: $halt _script = false;   $notify = true;   $label = "<B>Notice</B>";   Break   Case E_user_warning:case e_warning: $halt _script = false;   $notify = true;   $label = "<b>Warning</b>";   Break   Case E_user_error:case e_error: $label = "<b>fatal error</b>";   $notify =true;   $halt _script = false;   Break   Case E_parse: $label = "<b>parse error</b>";   $notify =true;   $halt _script = true;   Break   Default: $label = "<b>unknown error</b>";  Break   if ($notify) {$msg = $label. $error _msg;  Echo $msg; } if ($halt _script) exit-1;} $error _handler = Set_error_handler ("ErrHandler"); echo "&LT;BR&Gt;

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

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.