Common php error types and shielding methods

Source: Internet
Author: User
These are small and not serious errors, such as accessing an undefined variable. Generally, these errors are not prompted to the user, but sometimes these errors affect the running result. 1. Note (Notices)
These are small and not serious errors, such as accessing an undefined variable. Generally, these errors are not prompted to the user, but sometimes these errors affect the running result.

2. warning (Warnings)
This is a slightly serious error. for example, you want to include () A file that does not exist. This error message will prompt the user, but will not cause the program to stop running.

3. Fatal errors)

These are serious errors. for example, if you want to initialize a non-existent class object or call a non-existent function, these errors will cause the program to stop running, PHP will also display these errors to users.

Different error types include:

E_ERROR: it is usually displayed and the program execution is interrupted.
E_WARNING: usually displayed, but the execution of the program will not be interrupted.
E_NOTICE: code error that occurs when the script runs normally.
E_PARSE: syntax parsing error.

E_CORE_ERROR: a fatal error that occurs when PHP is started.
E_CORE_WARNING: reports non-fatal errors that occur when PHP is started.
E_COMPILE_ERROR: Fatal error during compilation, indicating a script error.

E_USER_ERROR: Error message generated by the user.
E_USER_WARNING: user-generated warning information.
E_USER_NOTICE: User-triggered attention message.

E_STRICT: indicates the code standardization warning. an error occurs during running.
E_RECOVERABLE_ERROR: near a fatal runtime error. if it is not captured, it is treated as E_ERROR.
E_ALL: capture all errors and warnings.

The methods for blocking PHP error messages are as follows:

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 messages.
Here, error_reporting configures the error information return level.

Syntax: int error_reporting (int [level]);
Return value: integer
Function types: PHP system functions

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.