php獲取錯(cuò)誤信息的方法
更新時(shí)間:2015年07月17日 11:21:55 作者:洞悉
這篇文章主要介紹了php獲取錯(cuò)誤信息的方法,涉及php針對(duì)錯(cuò)誤處理的常用技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
本文實(shí)例講述了php獲取錯(cuò)誤信息的方法。分享給大家供大家參考。具體如下:
function error_reg(){
$ar=array(
E_ERROR => 'error',
E_WARNING => 'warning',
E_PARSE =>'prase',
E_NOTICE => 'notice'
);
register_shutdown_function(function() use ($ar){
$ers=error_get_last();
if($ers['type']!=8 && $ers['type']){
$er=$ar[$ers['type']].$ers['type'].': '.' '.$ers['message'].' => '.$ers['file'].' line:'.$ers['line'].' '.date('Y-m-d H:i:s')."\n";
error_log($er,3,'/tmp/php_error.log');
}
});
set_error_handler(function($a,$b,$c,$d) use ($ar){
if($a!=8 && $a){
$er=$ar[$a].$a.': '.$b.' => '.$c.' line:'.$d.' '.date('Y-m-d H:i:s')."\n";
error_log($er,3,'/tmp/php_error.log');
}
},E_ALL ^ E_NOTICE);
}
希望本文所述對(duì)大家的php程序設(shè)計(jì)有所幫助。
相關(guān)文章
基于PHP導(dǎo)出Excel的小經(jīng)驗(yàn) 完美解決亂碼問題
本篇文章是對(duì)PHP導(dǎo)出Excel亂碼問題的解決方法就行了詳細(xì)的分析介紹,需要的朋友參考下2013-06-06
PHP mysqli_free_result()與mysqli_fetch_array()函數(shù)詳解
這篇文章主要介紹了PHP mysqli_free_result()與mysqli_fetch_array()函數(shù)詳解的相關(guān)資料,需要的朋友可以參考下2016-09-09

