Home  >  Article  >  Backend Development  >  error_reporting() function usage, errorreporting_PHP tutorial

error_reporting() function usage, errorreporting_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 09:44:50841browse

error_reporting() function usage, errorreporting

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 Compilation time parsing error. 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 at PHP startup. This is like an E_WARNING warning
64 E_COMPILE_ERROR fatal compile-time error in 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 notification.
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 is not enabled by default, so you need to configure the php.ini file:

Change display_errors = Off to display_errors = On

Also configure the error level: change

error_reporting = E_ALL changed 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. //Report runtime errors
    5. error_reporting(E_ERROR | E_WARNING | E_PARSE);
    6. //Report all errors
    7. error_reporting(E_ALL);
    8. ?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1048723.htmlTechArticleerror_reporting() function usage, errorreporting First of all, you must know that the error_reporting() function is used to set the error level and return the current level of. It has 14 error levels, as follows: 1 E_E...
Statement:
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