Customize PHP error report handling methods

Source: Internet
Author: User
: 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.