Register_shutdown_function error handling cannot print logs
陈健
陈健 2018-12-27 17:48:16
0
2
716
<?php
error_reporting(0);
register_shutdown_function('customSeriousError');

function customSeriousError()
{
    if ($err = error_get_last()) {
        file_put_contents('log.txt', '1231313', FILE_APPEND);
        // 可以退出,打印错误,但是没有输出日志
        exit(json_encode(array('code' => 500, 'message' => "error: [{$err['type']}] {$err['message']}  in  {$err['file']}  on  {$err['line']}")));
    }
}
class UTIL
{
    public static function returnMember($arg, $default=0)
    {
        var_dump($arg);
        var_dump($default);
        return $arg;
    }
}
UTIL::returnMember();
?>
陈健
陈健

reply all(1)
陈健

The PHP file is placed under the virtual host configured by Apache, but the log.txt entered in the file is still in the root directory of Apache, so there is no response to the log.txt in the virtual host directory

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!