Home > Backend Development > PHP Tutorial > error_reporting function usage

error_reporting function usage

WBOY
Release: 2016-07-30 13:30:11
Original
1186 people have browsed it

First of all, you must know that the error_reporting() function is used to set the error level and return the current level. It has 14 error levels, as follows:

1 E_ERROR Fatal runtime error. The error cannot be recovered from. Execution of the script was suspended
2 E_WARNING Non-fatal runtime error. The execution of the script will not stop
4 E_PARSE Parsing error during compilation. Parsing errors should only be generated by the analyzer
8 E_NOTICE runtime notifications.
16 E_CORE_ERROR Fatal error when starting PHP. This is like an E_ERROR
32 in the PHP core E_CORE_WARNING A non-fatal error when PHP starts. This is like an E_WARNING warning
64 E_COMPILE_ERROR fatal compile-time error in the PHP core. This is like an E_ERROR
128 E_COMPILE_WARNING non-fatal compile-time error generated by the Zend Scripting Engine, and an E_WARNING warning
256 E_USER_ERROR fatal user-generated error generated by the Zend Scripting Engine.
512 E_USER_WARNING Non-fatal user-generated warning.
1024 E_USER_NOTICE User generated notifications.
2048 E_STRICT Notification of running time.

4096 E_RECOVERABLE_ERROR Catches fatal errors.

8191 E_ALL for all errors and warnings.

It seems that php does not enable errors by default, so you need to configure the php.ini file:

Change display_errors = Off to display_errors = On

In addition, configure the error level: Change

error_reporting = E_ALL to:

error_reporting = E_ALL & ~E_NOTICE

It should be that php displays all errors by default, and we do not need to display some harmless prompts, so the settings are as above!

can also be used in php code as follows:

    1. php
    2. //Disable error reporting, that is, do not display errors
    3. error_reporting(0);
    4. //Reporting runtime errors
    5. error_reporting(E_ERROR | E_WARNING |E_PARSE);
    6. //Report all bugs
    7. error_reporting(E_ALL);
    8. ?>

The above introduces the usage of the error_reporting function, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template