1、因为项目已经上线了,所以调试起来就不可能把报错直接输出来,写了一个简单的日志函数如下:
//$log要添加的字符串、$filePrefix 日志名$fileSuffix 日志后缀$time默认为day
function AddLog($log='',$filePrefix='',$fileSuffix='.log',$time='day'){
$time1=date('Y-m-d H:i:s',time());
if($time=='year'){
$period=date('Y',time());
}elseif($time=='month'){
$period=date('Ym',time());
}elseif($time=='hour'){
$period=date('YmdH',time());
}elseif($time=='minute'){
$period=date('YmdHi',time());
}elseif($time=='second'){
$period=date('YmdHis',time());
}else{
$period=date('Ymd',time());
}
$filename=$filePrefix.$period.$fileSuffix;
$fp=fopen($filename,'a');
if($fp){
$wr=fwrite($fp,$time1."\n".$log."\n");
if($wr){
$close=fclose($fp);
if($close){
return 1;
}else{
return -1;
}
}else{
return -2;
}
}else{
return -3;
}
}
//要写入数据库的字符串
$str ='88888';
AddLog($str,'erdangjiade');exit;
PHP+Mysql网站源码学习请访问:PHP+Mysql网站源码学习请访问
http://www.erdangjiade.com/