PHP error types and shielding methods, and php error shielding

Source: Internet
Author: User
Tags php error

PHP error types and shielding methods, and php error shielding

As long as the program is running, errors will inevitably occur, which are common, such as Error, Notice, and Warning. In PHP, there are three main error types.

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:It is usually displayed, but the execution of the program will not be interrupted.

E_NOTICE:A code error 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:A fatal error occurred 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:Note message triggered by the user.

E_STRICT:Code standardization warning, an error occurred during running.

E_RECOVERABLE_ERROR:Near fatal runtime error. If not captured, it is considered as E_ERROR.

E_ALL:Capture all errors and warnings.

Block PHP error messages

Method 1:Add @ before a function that may have an error, and then or die ("") such:

@ 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

The above discussion about the PHP Error Type and blocking method is all the content shared by the editor. I hope to give you a reference and support for the help house.

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.