Set a user-defined error handler function with the set_error_handler() function, and trigger an error (with trigger_error()):
The above code will output something like this:
The set_error_handler() function sets a user-defined error handler function.
Note: The standard PHP error handler is completely bypassed if this function is used, and the user-defined error handler must terminate the script, die(), if necessary.
Note: If errors occur before the script is executed the custom error handler cannot be used since it is not registered at that time.
Parameter | Description |
---|---|
errorhandler | Required. Specifies the name of the function to be run at errors |
E_ALL|E_STRICT | Optional. Specifies on which error report level the user-defined error will be shown. Default is "E_ALL" |
Return Value: | A string that contains the previously defined error handler |
---|---|
PHP Version: | 4.0.1+ |
PHP Changelog: | PHP 5.5: The parameter errorhandler now accepts NULL PHP 5.2: The error handler must return FALSE to populate $php_errormsg |