<?PHP//custom Error handler//$errorno error number//$errmes error message//These two parameters are required functionMy_error ($errorno,$errmes) { Echo"<font size= ' 5 ' color= ' Red ' >$errorno</font><br/> "; Echo"The error message is:$errmes"; } //The Set_error_handler processor must be rewritten Set_error_handler("My_error",e_warning);//e_warning Error Level $fp=fopen("A.txt", "R"); Echo"<br/>"; Echo"<br/>"; Echo"<br/>"; Echo"<br/>"; Echo"<br/>"; //method should be defined in front//Custom error handler processing method functionMy_error2 ($errno,$errmes) { Echo"Error number:".$errno; } //changing the method of error trigger invocation Set_error_handler("My_error2",e_user_warning);//The error level here typically includes the user $age=700; if($age>120) { //trigger_error ("Input age is too large");//Error trigger [Invoke system default mode] Trigger_error("Input age is too large",e_user_warning); } ?>
PHP Learning Note 33 "Custom error Handler"