您好,欢迎访问一九零五行业门户网

PHP的error_reporting错误级别变量对照表,errorreporting_PHP教程

php的error_reporting错误级别变量对照表,errorreporting在php中所有的报错信息可以用error_reporting()这个函数来设置:
它的参数有字符串和数字两种表示方法,共14个等级,但是呢,我看使用其他数字貌似也可以,起初我以为它指的是一定的报错区间,后来,终于发现了其中的规律:
复制代码 代码如下:
error_reporting( 7 ) = error_reporting( 1+2+4)= error_reporting(e_error | e_waring | e_parse)
现在,我将其总结如下:
数字 常量 说明
1 e_error 致命错误,脚本执行中断,就是脚本中有不可识别的东西出现
举例: error:invalid parameters. invalid parameter name
2 e_warning 部分代码出错,但不影响整体运行
举例: warning: require_once(e:/include/config_base.php)
4 e_parse  字符、变量或结束的地方写规范有误
举例:  parse error: syntax error, unexpected $end in
8   e_notice 一般通知,如变量未定义等
举例:  notice: undefined variable: p in e:\web\index.php on line 17
16  e_core_error php进程在启动时,发生了致命性错误
举例:  暂无
32  e_core_warning 在php启动时警告(非致命性错误)
举例:  暂无
64 e_compile_error 编译时致命性错误
举例:  暂无
128 e_compile_warning 编译时警告级错误
举例:  暂无
256 e_user_error  用户自定义的错误消息
举例:  暂无
512 e_user_warning 用户自定义的警告消息
举例:  暂无
1024 e_user_notice  用户自定义的提醒消息
举例:  暂无
2047 e_all 以上所有的报错信息,但不包括e_strict的报错信息
举例:  暂无
2048 e_strict 编码标准化警告,允许php建议如何修改代码以确保最佳的互操作性向前兼容性。
error_reporting 变量的默认值是  e_all & ~e_notice
开发时,最佳的值为: e_all | e_strict
如果设置为:error_reporting(e_all | e_strict),则表示记录所有的错误信息
可能会导致网站出现一大堆的错误代码;但是对于程序员来说应该说是一件好事,可以把代码优化到最优; 一些非致命性错误虽然不影响程序的运行,但是会加重php的负担.
最后,晒出英文版的对照表:
1 e_error fatal run-time errors. errors that can not be recovered from. execution of the script is halted
2 e_warning non-fatal run-time errors. execution of the script is not halted
4 e_parse compile-time parse errors. parse errors should only be generated by the parser
8 e_notice run-time notices. the script found something that might be an error, but could also happen when running a script normally
16 e_core_error fatal errors at php startup. this is like an e_error in the php core
32 e_core_warning non-fatal errors at php startup. this is like an e_warning in the php core
64 e_compile_error fatal compile-time errors. this is like an e_error generated by the zend scripting engine
128 e_compile_warning non-fatal compile-time errors. this is like an e_warning generated by the zend scripting engine
256 e_user_error fatal user-generated error. this is like an e_error set by the programmer using the php function trigger_error()
512 e_user_warning non-fatal user-generated warning. this is like an e_warning set by the programmer using the php function trigger_error()
1024 e_user_notice user-generated notice. this is like an e_notice set by the programmer using the php function trigger_error()
2048 e_strict run-time notices. php suggest changes to your code to help interoperability and compatibility of the code
4096 e_recoverable_error catchable fatal error. this is like an e_error but can be caught by a user defined handle (see also set_error_handler())
8191 e_all all errors and warnings, except level e_strict (e_strict will be part of e_all as of php 6.0)
php error reporting 报告有什类型的错误报告
error_reporting()
在php中有四种类型的错误和警告。它们是:
通常函数错误:1
通常警告:2
分析错误:4
注释(警告用户,可以忽略该信息,但是这个问题可能给您的代码会带来一些错误):8
信息后面的四个数字是该信息类型的表示值,把它们加起来作为错误报告的级别。却省的报告级别是7(即1+2+4),或除了“注释”的其他组合。这个级别能够通过改变php3.ini文件中错误报告指示的方法来改变。它也可以在用户的httpd.conf文件中改变php3错误报告的方法来设置,或者在运行的时候使用脚本语言函数error_reporting()来改变
在php中,error_reporting(0)表示什?
不让php报告有错语发生。如果不关闭好有类似这样的错语
warning: preg_match()
关闭就不出现了
http://www.bkjia.com/phpjc/840752.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/840752.htmltecharticlephp的error_reporting错误级别变量对照表,errorreporting 在php中所有的报错信息可以用error_reporting()这个函数来设置: 它的参数有字符串和数字两...
其它类似信息

推荐信息