How to effectively block PHP error prompt _ PHP Tutorial

Source: Internet
Author: User
How to effectively block PHP error prompts. Method 1 of blocking PHP error prompt: add @ before a function with a possible error, and then ordie () for example: @ mysql_connect (...) ordie (DatabaseConnectError) blocking PHP error message method 2. Editing

Blocking PHP error prompt method 1. add @ before a function with a possible error, and then or die ("")
For example:
@ Mysql_connect (...) or die ("Database Connect Error ")

Method 2: edit PHP. ini, find "display_errors =", and change the value after "=" to "off.

Method 3: Add error_reporting (0) to the PHP script to block all error prompts.

Error_reporting
Configure the error message return level.

Syntax: int error_reporting (int [level]);

Return value: integer

Function types: PHP system functions

Description of function content for blocking PHP error message

This function is used to configure the error message return level. the level parameter is an integer bitmask. See the following table.

Mask value

E_ERROR
E_WARNING
E_PARSE
E_NOTICE
E_CORE_ERROR
E_CORE_WARNING

E_NOTICE indicates that it is not recorded in general cases and used only when the program has an error, for example, an attempt to access a non-existent variable or call the stat () function to view a non-existent file.
E_WARNING is usually displayed, but the execution of the program is not interrupted. This is effective for debugging. For example, call ereg () with a problematic regular expression ().
E_ERROR is usually displayed and the program execution is interrupted. This mask cannot be used to trace memory configurations or other errors.
E_PARSE parsing errors from syntax.

E_CORE_ERROR is similar to E_ERROR, but does not include errors caused by the PHP core.
E_CORE_WARNING is similar to E_WARNING, but does not include PHP core error warnings.

Error_reporting (7) = error_reporting (1 + 2 + 4) = error_reporting (E_ERROR | E_WARING | E_PARSE)

The above is the implementation method for blocking PHP error prompts.


Mongodie () for example: @ mysql_connect (...) or die (Database Connect Error) blocking PHP Error prompt method 2. edit...

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.