PHP报错信息的函数说明
发表于:2024-10-24 作者:千家信息网编辑
千家信息网最后更新 2024年10月24日,这篇文章主要讲解了"PHP报错信息的函数说明",文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习"PHP报错信息的函数说明"吧!在PHP中所有的报错信息可以用
千家信息网最后更新 2024年10月24日PHP报错信息的函数说明
这篇文章主要讲解了"PHP报错信息的函数说明",文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习"PHP报错信息的函数说明"吧!
在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报错信息的函数说明"的内容了,经过本文的学习后,相信大家对PHP报错信息的函数说明这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是,小编将为大家推送更多相关知识点的文章,欢迎关注!
错误
信息
代码
函数
致命性
变量
数字
消息
用户
学习
内容
字符
就是
程序
脚本
影响
编译
运行
东西
兼容性
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
游戏软件开发项目培训
剑侠情缘3金山版服务器
内模式是面向数据库用户
织梦cms数据库配置文件
网络安全与法治工作思路
数据库软件sc
南京苹果手机软件开发
服务器管理员能看见吗
香港不限内容服务器
怎么查服务器数据量
网络安全审查意味什么意思
数据库技术及应用实训体会
数据库中下划线意思
留守儿童网络安全视频
国产串口服务器多少钱
网络管理员和网络技术员
国产化 软件开发经验
做一个交友数据库
网络安全专业搜题软件
北京必火网络安全培训机构
开一家数据库公司的
高中网络技术软件
码字工坊网络技术有限公司
怎样把服务器变成一台虚拟机
远程服务器玩pokemmo
亚美互联网科技有限公司
万方数据库的
h5代码上传到服务器
安徽无线网络技术管理系统
服务器被举报了怎么办