PHPset_error_handler () function 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 returns the old error handler. if it fails, null is returned.
Syntax set_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, it will completely bypass the standard PHP error handler. 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
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: [1024] A custom error has been triggeredError on line 19 in C:\webfolder\test.phpEnding Script