日志文件写入
function write_log($dir,$array,$title=""){
$string = array();
if(is_array($array)){
foreach ($array as $key=> $value){
array_push($string, $key.'->'.$value);
}
$content = implode(',',$string);
}else{
$content = $array;
}
if(!is_dir($dir)){
mkdir($dir);
}
$filename = date('Ymd').'-'.$title.'.log';
//echo $dir;die;
//file_put_contents("log.txt", "Hello world everyone.".PHP_EOL, FILE_APPEND);die;
$result = file_put_contents( $dir.'/'.$filename,(date('Y-m-d H:i:s',time())).' '.$content."\r\n",FILE_APPEND | LOCK_EX );
return $result;
}
write_log('/alidata/logs/project/test_222',"666666",$title="1");