PHP头条
热点:

[PHP] php的register_shutdown_function,


<u></u>register_shutdown_function注册的函数会在脚本正常执行完和异常结束的时候触发。

例如:

register_shutdown_function("globalErrorHandler");

function globalErrorHandler(){
    $error=error_get_last();
        
    if($error===null){
        return;
    }
        
    echo json_encode($error);
}

注意:
(1)如果没有错误,则error_get_last返回null
(2)脚本正常执行完,也会调用这个函数,所以要通过$error是否为null进行区分
(3)$error是一个array,包含type,message,file,line这些键名

www.phpzy.comtrue/php/25226.htmlTechArticle[PHP] php的register_shutdown_function, u/u register_shutdown_function 注册的函数会在脚本正常执行完和异常结束的时候触发。 例如: register_shutdown_function("globalErrorHandler");function globalErrorHandler(){ $...

相关文章

    暂无相关文章

PHP之友评论

今天推荐