: This article mainly introduces how to handle custom PHP error reports. if you are interested in PHP tutorials, refer to it. Let php prompt the error message according to our method.
Function used: set_error_handler ()
Syntax
Set_error_handler (error_handler, error_types );
Parameters
Error_function is required. Specifies 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 ".
Instance:
'; Echo' error message: '. $ errstr .'
'; Echo' error File: '. $ errfile .'
'; Echo' error row: '. $ errline; die () ;}?>
Original error:
The following error is reported:
Extension:
Trigger_error () function is used to trigger an error message under user-specified conditions.
Trigger_error: This function is easy to remember the trigger function in jquery.
Purpose:
It is used to trigger an error message under the conditions specified by the user. It is used together with the built-in error processor, or with user-defined functions created by the set_error_handler () function.
If an invalid error type is specified, the function returns false; otherwise, the function returns true.
Syntax:
Trigger_error (error_message, error_types)
Error_message is required. Specifies the error message. It can be up to 1024 characters in length.
Error_types is optional. Specifies the error type of the error message. Possible value: E_USER_ERROR E_USER_WARNING E_USER_NOTICE
Example:
1) {trigger_error ("test cannot be greater than 2") ;}?>
The preceding section describes how to handle custom PHP error reports, including related content. I hope my friends who are interested in PHP tutorials will be helpful.