PHP Custom error handling Usage instance, PHP Custom usage Example _php tutorial

Source: Internet
Author: User

PHP Custom error handling Usage instance, PHP custom usage instance


The examples in this article describe the use of custom error handling in PHP. Share to everyone for your reference. Specific as follows:

<?phperror_reporting (e_all); function ErrHandler ($errorno, $errorstr, $errorfile, $errorline) {$display = true;  $notify = false;  $halt _script = false; $error _msg = "
The $errorno error is occurring on $errorline in $errorfile
"; Switch ($errorno) {case E_user_notice:case e_notice: $halt _script = false; $notify = true; $label = "Notice"; Break Case E_user_warning:case e_warning: $halt _script = false; $notify = true; $label = "Warning"; Break Case E_user_error:case e_error: $label = "Fatal Error"; $notify =true; $halt _script = false; Break Case E_parse: $label = "Parse Error"; $notify =true; $halt _script = true; Break Default: $label = "Unknown Error"; Break if ($notify) {$msg = $label. $error _msg; Echo $msg; } if ($halt _script) exit-1;} $error _handler = Set_error_handler ("ErrHandler"); echo "

Using Custom Error Handler


"; Trigger_error ("
Error caused by E_user_notice
", E_user_notice); Trigger_error ("
Error caused by e_user_warning
", e_user_warning); Trigger_error ("
Error caused by e_user_error
", E_user_error); Trigger_error ("
Error caused by e_parse
", E_parse);? >

I hope this article is helpful to everyone's PHP programming.

http://www.bkjia.com/PHPjc/970981.html www.bkjia.com true http://www.bkjia.com/PHPjc/970981.html techarticle PHP Custom error handling usages instance, PHP Custom Usage Example This article describes the PHP custom error handling usage. Share to everyone for your reference. Specific as follows: Phperror_repo ...

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