PHP error types and Shielding methods

Source: Internet
Author: User
Tags php error

Php

Types of errors and shielding methods

1.

Note

Notices

These are small and not serious errors,

For example, to access a variable that is not defined.

Usually

This type of error is

Not prompt to the user, but sometimes these errors can affect the results of the run.

2.

Warning

Warnings

This is a slightly more serious mistake,

For example, to include

Include ()

A file that does not exist itself.

Such a mistake

The information is prompted to the user, but does not cause the program to terminate running.

3.

Fatal Error (

Fatal errors

These are serious mistakes,

For example, if you want to initialize an object of a class that doesn't exist,

or call a non-existent

function, these errors can cause 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 that occurred while the script was running correctly.

E_parse

: Syntax parsing error.

E_core_error

: In

Php

A fatal error occurred at startup.

E_core_warning

: Reports on

Php

A non-fatal error occurred at startup.

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, error during run time.

E_recoverable_error

: Near-fatal run-time error, if not captured

E_error

E_all

: Captures all errors and warnings.

Shielding

Php

Error hints

Method One: Before a function that is likely to fail, add

@,

And then

Or Die ("")

Such as:

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

Method Two: Edit

Ini

Find

"Display_errors ="

Will

=

The following value changes to

"Off

Method Three: In

Php

Script before adding

Error_reporting (0)

To block all error prompts.

which

Error_reporting

Configure the level of error message return.

Grammar:

int error_reporting (int [level]);

return value: Integer

Function Type:

Php

System functions

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.