Definition and usage
Set_error_handler () function to set custom error handling functions
This function is used to create your own error handling methods during runtime.
This function will return the old error handlingProgramIf it fails, null is returned.
SyntaxSet_error_handler (error_function, error_types)
The error_function parameter description is required to specify the function to run when an error occurs.
Error_types is optional. Specifies at which error report level a user-defined error will be displayed. The default value is "e_all ".
Tips and comments
Tip:If this function is used, the standard PHP error handler function is completely bypassed. If necessary, the user-defined error handler must terminate the (die () script.
Note: if an error occurs before the script is executed, the custom error handler will not be used because the custom program has not been registered at that time.
Example
<? PHP // Error handler Function Function Customerror ( $ Errno , $ Errstr , $ Errfile , $ Errline ){ Echo "<B> custom error: </B> [ $ Errno ] $ Errstr <Br/>" ; Echo "Error on line $ Errline In$ Errfile <Br/>" ; Echo "Ending script" ; Die ();} // Set error handler Set_error_handler ("Customerror" ); $ Test = 2 ; // Trigger Error If ($ Test > 1 ){ Trigger_error ("A custom error has been triggered" );} ?>
Output:
Custom error: [1, 1024] A custom error has been triggerederror on line19 In c: \ webfolder \ test.Phpending script