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