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();         //恢复错误信息指针

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值