博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PHP error_reporting() 函数
阅读量:6415 次
发布时间:2019-06-23

本文共 1856 字,大约阅读时间需要 6 分钟。

hot3.png

定义和用法

error_reporting() 设置 PHP 的报错级别并返回当前级别。

语法

error_reporting(report_level)

如果参数 level 未指定,当前报错级别将被返回。下面几项是 level 可能的值:

常量 描述
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)

例子

任意数目的以上选项都可以用“或”来连接(用 OR 或 |),这样可以报告所有需要的各级别错误。例如,下面的代码关闭了用户自定义的错误和警告,执行了某些操作,然后恢复到原始的报错级别:

转载于:https://my.oschina.net/ajian2014/blog/323000

你可能感兴趣的文章
2014年 生活大爆炸版石头剪刀布
查看>>
Cocos2d-x开发---关于内存检测
查看>>
git shell 命令
查看>>
Revit插件获取数据Bug的解决1
查看>>
如何将matlab画出的图片保存为要求精度
查看>>
淘宝实习面试经历分享
查看>>
帮Customer Architecture写的小脚本
查看>>
Calling a Batch File/EXE from an SQR
查看>>
Message Box
查看>>
坐标轴的旋转及绕某一点旋转后坐标值求解
查看>>
KVO 简单使用
查看>>
如何在Linux终端里用Shell和C输出带颜色的文字
查看>>
REST framework
查看>>
awk中begin/end的含义
查看>>
windows下流媒体nginx-rmtp-module服务器搭建及java程序调用fmpeg将rtsp转rtmp直播流【转】...
查看>>
vlc的应用之三:动态调用vlc-0.9.4的libvlc.dll【转】
查看>>
Web API核查表:设计、测试、发布API时需思考的43件事[转]
查看>>
Eclipse使用技巧
查看>>
webkit webApp 开发技术要点总结
查看>>
MVC下用户登录状态校验的问题以及解决方案--------------Action全局过滤器的使用...
查看>>