码迷,mamicode.com
首页 > Web开发 > 详细

php register_shutdown_function响应error 配合error_get_last 捕获错误

时间:2017-07-10 16:40:20      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:存在   nbsp   pre   callback   tmp   erro   back   function   port   

转自:

http://blog.csdn.net/a757291228/article/details/62231125

 

//一个函数,用来响应 register_shutdown_function

function shutdownCallback($logPath=‘/tmp/z.log‘){

    $arrError = error_get_last(); //使用 error_get_last 能捕获错误,等下说明
   
    $date = date(‘Y-m-d H:i:s‘, time());
    
    file_put_contents($logPath, "[".$date."]".var_export($arrError, true)."\r\n", FILE_APPEND);
}


register_shutdown_function("shutdownCallback");//如果出现错误则执行 shutdownCallback 触发器一样的存在

$b = new aa(); //  错误的代码

 

php register_shutdown_function响应error 配合error_get_last 捕获错误

标签:存在   nbsp   pre   callback   tmp   erro   back   function   port   

原文地址:http://www.cnblogs.com/dongruiha/p/7145881.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!