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

转自:

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)."
", FILE_APPEND);
}


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

$b = new aa(); //  错误的代码
原文地址:https://www.cnblogs.com/dongruiha/p/7145881.html