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

php中error_reporting函数用法详解_PHP教程

在php中error_reporting是设置 php 的报错级别并返回当前级别,我们可以根据不同级别来设置是不给出错误提示域外出错时是否向往执行程序,下面我来介绍error_reporting()用法与参数。
基本信息
e_notice 表示一般情形不记录,只有程序有错误情形时才用到,例如企图存取一个不存在的变量,或是呼叫 stat() 函数检视不存在的文件。
e_warning 通常都会显示出来,但不会中断程序的执行。这对除错很有效。例如:用有问题的正则表达式呼叫 ereg()。
e_error 通常会显示出来,亦会中断程序执行。意即用这个遮罩无法追查到内存配置或其它的错误。
e_parse 从语法中解析错误。
e_core_error 类似 e_error,但不包括 php 核心造成的错误。
e_core_warning 类似 e_warning,但不包括 php 核心错误警告。
例子:
error_reporting = e_all & ~e_notice ; 显示所有的错误,除了提醒
error_reporting = e_compile_error|e_error|e_core_error ; 仅显示错
error_reporting=e_error :只会报告致命性错误
基本上设置
error_reporting = e_all & ~e_notice ; 显示所有的错误,除了提醒
例子
 代码如下 复制代码
error_reporting(0);
// report simple running errors
error_reporting(e_error | e_warning | e_parse);
// reporting e_notice can be good too (to report uninitialized
// variables or catch variable name misspellings ...)
error_reporting(e_error | e_warning | e_parse | e_notice);
// report all errors except e_notice
// this is the default value set in php.ini
error_reporting(e_all ^ e_notice);
// report all php errors (bitwise 63 may be used in php 3)
error_reporting(e_all);
// same as error_reporting(e_all);
ini_set('error_reporting', e_all);
整数。表示旧的php的错误级别。(returns the old error_reporting level.)
手册上的例子:
value constant description note
1 e_error (integer) fatal run-time errors. these indicate errors that can not be recovered from, such as a memory allocation problem. execution of the script is halted.  
2 e_warning (integer) run-time warnings (non-fatal errors). execution of the script is not halted.  
4 e_parse (integer) compile-time parse errors. parse errors should only be generated by the parser.  
8 e_notice (integer) run-time notices. indicate that the script encountered something that could indicate an error, but could also happen in the normal course of running a script.  
16 e_core_error (integer) fatal errors that occur during php’s initial startup. this is like an e_error, except it is generated by the core of php. since php 4
32 e_core_warning (integer) warnings (non-fatal errors) that occur during php’s initial startup. this is like an e_warning, except it is generated by the core of php. since php 4
64 e_compile_error (integer) fatal compile-time errors. this is like an e_error, except it is generated by the zend scripting engine. since php 4
128 e_compile_warning (integer) compile-time warnings (non-fatal errors). this is like an e_warning, except it is generated by the zend scripting engine. since php 4
256 e_user_error (integer) user-generated error message. this is like an e_error, except it is generated in php code by using the php function trigger_error(). since php 4
512 e_user_warning (integer) user-generated warning message. this is like an e_warning, except it is generated in php code by using the php function trigger_error(). since php 4
1024 e_user_notice (integer) user-generated notice message. this is like an e_notice, except it is generated in php code by using the php function trigger_error(). since php 4
2048 e_strict (integer) run-time notices. enable to have php suggest changes to your code which will ensure the best interoperability and forward compatibility of your code. since php 5
4096 e_recoverable_error (integer) catchable fatal error. it indicates that a probably dangerous error occured, but did not leave the engine in an unstable state. if the error is not caught by a user defined handle (see also set_error_handler()), the application aborts as it was an e_error. since php 5.2.0
8191 e_all (integer) all errors and warnings, as supported, except of level e_strict in php 6143 in php 5.2.x and 2047 previously
http://www.bkjia.com/phpjc/631263.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/631263.htmltecharticle在php中error_reporting是设置 php 的报错级别并返回当前级别,我们可以根据不同级别来设置是不给出错误提示域外出错时是否向往执行程序,下...
其它类似信息

推荐信息