Error processor and trigger

Source: Internet
Author: User

[Error level]

2 e_warning: non-fatal run-time error. Do not pause script execution. 8 e_notice: Run-time notification. An error may occur when the script runs normally. 256 e_user_error: Fatal user-generated error. E_error set by trigger_error. 512 e_user_warning: non-fatal user-generated warning. E_warning set by trigger_error. 1024 e_user_notice: user-generated notification. E_notice set by trigger_error. 4096 e_recoverable_error: a fatal error that can be captured. Similar to e_error, but can be captured by a user-defined handler. 8191 e_all: all errors and warnings.

 

1. Error processor (syntax error, custom system error) [set_error_handler ();]

<? PHP function myerror ($ errorno, $ errormsg) {echo 'error row number :'. $ errorno; echo 'error message :'. $ errormsg; exit ();} set_error_handler ("myerror", e_warning); $ fp = fopen ("abc.txt", "R");?>

2. Error trigger (correct syntax, self-righteous user error) [trigger_error (); error_log ();]

<? PHP function myerror ($ errorno, $ errormsg) {echo 'error row number :'. $ errorno; echo 'error message :'. $ errormsg; date_default_timezone_set ("PRC"); $ err_info = $ errorno. '--'. $ errormsg; // "\ r \ n" indicates the carriage return and line feed error_log ("time :". data ("Y-m-d h-I-s "). "-- error message :". $ err_info. "\ r \ n", 3, "errlog.txt"); exit ();} set_error_handler ("myerror", e_user_warning); $ age = 200; if ($ age> 200) {trigger_error ("the input age is too large", e_user_warning); exit () ;}?>

 

Error processor and trigger

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.