PHP Basic Tutorial Common PHP error types and Shielding methods

Source: Internet
Author: User
Tags php error php script

Basic PHP Tutorials Common PHP Error types and Shielding methods

as long as the program is running, there will inevitably be errors, errors are common, such as Error,notice,warning and so On. This article brother even PHP training Small to tell you specifically about PHP error types and shielding METHODS. In php, there are 3 main types of Errors.

1. Note (notices)

These are small and not serious errors, such as accessing a variable that is not Defined. typically, This type of error is not prompted to the user, but sometimes these errors can affect the result of the Run.

2. Warning (Warnings)

This is a slightly more serious mistake, such as wanting to include an include () file that does not exist ITSELF. Such an error message will prompt the user, but will not cause the program to stop Running.

3. Fatal error (Fatal Errors)

These are serious errors, such as if you want to initialize an object of a class that doesn't exist at all, or call a nonexistent function that causes the program to stop Running. PHP will also show these errors to the User.

Different types of errors include:

E_error: It is usually displayed, and the program execution is Interrupted.

E_warning: it is usually displayed but does not interrupt the execution of the Program.

E_notice: a code error occurred while the script was running Correctly.

E_parse: Syntax parsing Error.

E_core_error: A fatal error occurred while PHP was booting.

E_core_warning: reports Non-fatal errors that occur when PHP is Started.

E_compile_error: A fatal error occurred at compile time, indicating a script Error.

E_user_error: user-generated Error Message.

E_user_warning: user-generated Warning Message.

E_user_notice: user-raised Note message.

E_strict: encoding Normalization warning, run-time Error.

E_recoverable_error: near-fatal run-time errors, if not captured, are treated as E_error.

E_all: captures all errors and warnings.

Shielding PHP Error hints

method one: Add @ Before a function that is likely to go wrong, and then or Die ("")

Such as:

@mysql_connect (...) or Die ("Database connect Error")

method Two: Edit php.ini, look for "display_errors =" and change the value after "=" to "off."

method three: Add error_reporting (0) before the php script to block all error prompts.

among them,error_reporting configures the level of return for error Messages.

syntax:int error_reporting (int [level]);

Return value: integer

function Type: PHP System Features


PHP Basic Tutorial Common PHP error types and Shielding methods

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.