Home  >  Article  >  Backend Development  >  What are the php error levels?

What are the php error levels?

(*-*)浩
(*-*)浩Original
2019-10-09 14:03:413734browse

error_reporting()

What are the php error levels?

## is used to set the PHP error reporting level and return the current level. (PHP 4, PHP 5) (Recommended learning:

PHP Video Tutorial) The

function can set the error_reporting directive at runtime.

PHP has many error levels. Use this function to set the level when the script is running.

If the optional parameter level is not set, error_reporting() will only return the current error reporting level.

Deprecated 最低级别错误,程序继续执行
Notice 通知级别的错误 如直接使用未声明变量,程序继续执行
Warning 警告级别的错误,可能得不到想要的结果
Fatal error  致命级别错误致命级别错误,程序不往下执行
parse error 语法解析错误,最高级别错误,连其他错误信息也不呈现出来
E_USER_相关错误 用户设置的相关错误

How to set the error level?

error_reporting(-1) displays all errors, error_reporting(0) masks all errors

. ini_set('error_reporting',0) also masks all errors.

Error_reporting can be set in the php.ini file to make the script display or not display certain errors. ini_set('display_errors','On') displays errors.

Note: error_reporting() sets what kind of errors are reported, and ini_set('display_errors','On') sets whether errors are output. Thus error_reporting(-1) and ini_set('display_errors',0) can be used to set the log: errors are reported and not output.

Example:

error_reporting(E_ALL&~E_NOTICE)不显示通知级别的错误。“~”表示非。

The above is the detailed content of What are the php error levels?. For more information, please follow other related articles on the PHP Chinese website!

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