PHP script error handling method (PHP practice manual reading notes)

Source: Internet
Author: User
: This article mainly introduces how to handle PHP script errors (PHP practice manual reading notes). If you are interested in PHP tutorials, refer to it. What information should be output?

Various problems may occur when running PHP scripts, including user-level errors and system-level errors, which are useful to developers, then it is not necessarily useful for users (but users still want to see descriptive information about some errors). how can we display these error messages?
Here, we define a switch variable. when this variable is in the "open" status, we will output an error message. when this variable is in the "off" status, we ignore the error message. here we use a function to implement this function.

define(“DEBUG_MODE”,true);functiondebug_print($message){if(DEBUG_MODE)    {        echo$message    }}

In this way, we can control the output of information.

Where is the error message output?

When writing a PHP script, we usually implement a unified error message output page first. when the PHP script fails to run, we will jump to this error page, so how is the function of this error jump implemented? see the code:

functionhandle_error($usr_error_message, $system_error_message){    header("Location:show_error.php?error_message={$usr_error_message}&system_error_message={$system_error_message}");}

In this way, we can process the error information in the show_error.php file on the unified error output page.

'). AddClass ('pre-numbering '). hide (); $ (this ). addClass ('Has-numbering '). parent (). append ($ numbering); for (I = 1; I <= lines; I ++) {$ numbering. append ($ ('
  • '). Text (I) ;}; $ numbering. fadeIn (1700) ;}) ;}; script

    The above introduces the PHP script error handling method (PHP practice manual reading notes), including some content, hope to be helpful to friends who are interested in PHP tutorials.

    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.