Jquery中文网 www.jquerycn.cn
Jquery中文网 >  脚本编程  >  php  >  正文 php 错误报告开启详细实现

php 错误报告开启详细实现

发布时间:2019-03-13   编辑:www.jquerycn.cn
jquery中文网为您提供php 错误报告开启详细实现等资源,欢迎您收藏本站,我们将为您提供最新的php 错误报告开启详细实现资源

定义和用法
error_reporting() 设置 php 的报错级别并返回当前级别。

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

*/
//关闭所有的错误报告
error_reporting(0);
//只报告运行错误
error_reporting(e_error|e_warning|e_parse);
//报告e_notice
error_reporting(e_error|e_warning|e_parse|e_notice);
//报告所有的运行错误,除了e_notice
//这是php.ini的默认值
error_reporting(e_all ^ e_notice);
//报告所有的php错误
error_reporting(e_all);
//和error_reporting(e_all)有一样的功效,该设置也会报告所有php错误
ini_set('error_reporting', e_all);

/*

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

*/

function unserialize_handler($errno,$errstr)     //自定义函数
{
  echo "invalid serialized value.n";       //输出指定内容
}
$serialized='foo';          //定义字符串
set_error_handler('unserialize_handler');      //设置用户自定义错误信息函数
$original=unserialize($serialized);       //从已存储的表示中创建php的值
restore_error_handler();         //恢复错误信息指针

您可能感兴趣的文章:
开启php报错的命令是什么
php 错误报告开启详细实现
php 忽略错误
php错误显示配置
开发模式与产品模式下的PHP报错处理详解
php设置错误级别
php服务器报错怎么开启?
php error_reporting() 设置错误报告级别
php设置报错
php的报错级别有哪些?

[关闭]