error_reporting()
定义和用法
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 或 |),这样可以报告所有需要的各级别错误。例如,下面的代码关闭了用户自定义的错误和警告,执行了某些操作,然后恢复到原始的报错级别:
<?php
//禁用错误报告
error_reporting(0); //报告运行时错误
error_reporting(E_ERROR | E_WARNING | E_PARSE); //报告所有错误
error_reporting(E_ALL);
?>
error_reporting()的更多相关文章
- PHP 位运算(&, |, ^, ~, <<, >>)及 PHP错误级别报告设置(error_reporting) 详解
位运算符允许对整型数中指定的位进行求值和操作. 位运算符 例子 名称 结果 $a & $b And(按位与) 将把 $a 和 $b 中都为 1 的位设为 1. $a | $b Or(按位或) ...
- 以下C#程序的输出结果是( )。
以下程序的输出结果是( ). using System; namespace HoverTreeTikuConsole { class Program { static void Main(strin ...
- 页面加载完成后,触发事件——trigger()
<button id="btn">点击我</button> <div id="test"></div> 如果页面 ...
- linux/unix 编程手册 fork()函数
父进程通过fork()函数创建子进程,将父进程数据段和栈的内容拷贝到子进程中,子进程执行程序execve创建新程序,调用exit函数退出到等待wait(),挂起父进程, 父子进程享用相同的程序文本段. ...
- setInterval()与clearInterval()的一个有趣小现象
今天在使用setInterval()时,发现了一个有意思的事情 代码如下: var box=document.getElementById("box");//获取id为“box”的 ...
- HTML DOM对象之createElement()方法
今天在学习DOM节点操作时,发现了创建DOM节点的createElement()方法的一个有意思的现象. 代码如下: var box=document.getElementById("box ...
- join()方法之我见
JavaScript join() 方法 定义和用法 join() 方法用于把数组中的所有元素放入一个字符串. 元素是通过指定的分隔符进行分隔的. 语法 arrayObject.join(separa ...
- 转义字符(\)对JavaScript中JSON.parse的影响概述
JSON是一个提供了stringify和parse方法的内置对象,前者用于将js对象转化为符合json标准的字符串,后者将符合json标准的字符串转化为js对象,本文为大家介绍下转义字符对JSON.p ...
- 14、java中的equals()和toString()方法
/* 所有对象的父类Object Object中的方法: equals() 对象是否相同的比较方法 toString()对象的字符串表现形式 */ class Person { String name ...
随机推荐
- hadoop如何处理长时间运行不完成的map/reduce 任务?
如果某一个任务在某个节点上长时间不完成,怎么手动干预来处理这种情况?董西成博客上找到的回答:hadoop中有三种特殊的任务,failed task,killed task和speculative ta ...
- Lucene TF-IDF 相关性算分公式(转)
Lucene在进行关键词查询的时候,默认用TF-IDF算法来计算关键词和文档的相关性,用这个数据排序 TF:词频,IDF:逆向文档频率,TF-IDF是一种统计方法,或者被称为向量空间模型,名字听起来很 ...
- NYOJ-取石子
(一) 描述一天,TT在寝室闲着无聊,和同寝的人玩起了取石子游戏,而由于条件有限,他/她们是用旺仔小馒头当作石子.游戏的规则是这样的.设有一堆石子,数量为N(1<=N<=1000000), ...
- NVIDIA显卡设置
在玩3D游戏时,因为我的显卡不是特别给力,所以针对性能做出牺牲质量换取性能的调整. 简单设置 简单的方法是,3D设置-通过预览调整图像设置,根据偏重点来设置平衡:性能或者质量. 高级设置 如果你想自行 ...
- MySQL 基础语句的练习2
CREATE TABLE student ( id INT, NAME ), Chinese FLOAT, English FLOAT, Math FLOAT ); ,,,); ,,,); ,,,); ...
- java 继承(下)
1.抽象方法一定要写在抽象类中. 2.抽象类只在描述该事事务应该具备的东西. 3.抽象只能是抽象类和抽象方法. 4,抽象类没有任何抽象方法,这种类是不让创建对象. private static
- Centos6 安装 Redis
先确认gcc和tcl已经安装 sudo yum install gcc-c++ sudo yum install tcl 解压, 编译和安装 .tar.gz /usr/src/ cd /usr/src ...
- 单机多实例Tomcat部署
单机单用户基础上, 如何运行多个tomcat实例. 首先是tomcat的目录结构 bin – 包含所有运行tomcat的二进制和脚本文件 lib – 包含tomcat使用的所有共享库 c ...
- workqueue机制分析之process_one_work分析
工作者线程不断执行,从work_poll结构中卸下一个work, 然后进入函数process_one_work 来执行这个work. process_one_work(struct worker *w ...
- SQL2012删除作业失败的处理
修改msdb数据库中的过程sp_delete_job,如下: USE [msdb] GO /****** Object: StoredProcedure [dbo].[sp_delete_job] S ...