Home  >  Article  >  Backend Development  >  PHP error level collection_PHP tutorial

PHP error level collection_PHP tutorial

WBOY
WBOYOriginal
2016-07-14 10:07:14844browse

In many cases, our PHP files will have some errors that are very difficult to troubleshoot, such as outputting a large white page, and there is no way to fix the error. It is possible that PHP's error level blocks some non-fatal errors, resulting in no error prompts. Therefore, understanding and becoming familiar with PHP error levels may become a new method for debugging.
​​​​ Error reporting level in php.ini By default, the PHP error reporting level is E_NOTICE. E_ALL means to report all non-fatal errors, because these errors may cause big problems (such as using undefined variables).

Shows all errors except alerts and coding standardization warnings.

Error reports are bit fields. You can add up the numbers to get the desired level of error reporting.

E_ALL - all errors and warnings (excluding E_STRICT)

E_ERROR - Fatal runtime error

E_WARNING - runtime warning (non-fatal error)

E_PARSE - compile-time parsing error

E_NOTICE - Runtime reminders (these are often caused by bugs in your code, or may be caused by intentional behavior.)

E_STRICT - Encoding standardization warning, allowing PHP to recommend how to modify the code to ensure optimal interoperability and forward compatibility.

E_CORE_ERROR - Fatal error during initialization during PHP startup

E_CORE_WARNING - Warning during initialization process when PHP starts (non-fatal error)

E_COMPILE_ERROR - Fatal compile-time error

E_COMPILE_WARNING - compile-time warning (non-fatal error)

E_USER_ERROR - User-defined error message

E_USER_WARNING - User-defined warning message

E_USER_NOTICE - User-defined reminder message

If set to: E_ALL | E_STRICT, it means recording all error information, which may cause a lot of error codes to appear on the website; but it should be said to be a good thing for programmers, who can optimize the code to the best; some Although non-fatal errors do not affect the operation of the program, they will increase the burden on PHP, usually increasing the burden on the website process (such as the application pool of IIS).
Tweak error reporting in PHP
Once PHP is set up to display what errors occur, you may want to adjust the level of error reporting. A PHP installation as a whole or as a stand-alone script can be set up to report or ignore different error levels. Table 7-1 lists most levels, but they generally fall into one of three categories:
l Note (notice), this will not prevent the execution of the script and may not necessarily be a problem;
l Warning, which indicates a problem but does not prevent the execution of the script;
l Errors, which prevent the script from continuing (including common parsing errors, which essentially prevent the script from running).
Table 7-1 PHP error reporting settings, used with the error_reporting() function, or in the php.ini file. Note that the value of E_ALL is different from older versions of PHP and does not include E_STRICT (but exists in PHP 6)

编    号 常    量 报    告
1 E_ERROR 致命的运行时错误(它会阻止脚本的执行)
2 E_WARNING 运行时警告(非致命的错误)
(continued)
编    号 常    量 报    告
4 E_PARSE 解析错误
8 E_NOTICE 注意(事情可能是或者可能不是一个问题)
256 E_USER_ERROR 用户生成的错误消息,由trigger_error()函数生成
512 E_USER_WARNING 用户生成的警告,由trigger_error()函数生成
1024 E_USER_NOTICE 用户生成的注意,由trigger_error()函数生成
2048 E_STRICT 关于兼容性和互操作性的建议
8191 E_ALL 所有的错误、警告和建议

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/477861.htmlTechArticleIn many cases, our PHP files will have some errors that are very difficult to troubleshoot, such as outputting large white pages and debugging errors. No way to start. It's possible that PHP's error level blocks some non-fatal...
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