Definition and usage
The Set_error_handler () function sets the user-defined error handling function
This function is used to create the user's own error handling method during runtime.
The function returns the old error handler and returns null if it fails.
Grammar Set_error_handler (error_function,error_types)
Parameter description error_function required to specify the function to run when an error occurs.
Error_types is optional. Specifies the error reporting level at which user-defined errors are displayed. The default is "E_all".
Hints and Notes
Tip: If you use this function, the standard PHP error handler is completely bypassed, and if necessary, the user-defined error handler must terminate (Die ()) script.
Note: If an error occurs before the script executes, the custom error handler is not used because the custom program is not registered at that time.
Example
Custom error: [$errno] $errstr
"; echo "Error on line $errline in $errfile
"; echo "Ending Script"; Die (); }//set error Handlerset_error_handler ("Customerror"); $test =2;//trigger Errorif ($test >1) {trigger_error ("A Custom Error has been triggered "); }?>
Output:
Custom error: [1024x768] A custom error has been triggerederror on line C:\webfolder\test.phpEnding Script