php简单日志写入函数
程序员文章站
2023-04-06 09:53:55
1 function showLog($content,$filename="filenamelog") 2 { 3 $logfile = 'logs/'.$filename.date('Ymd').'.txt'; 4 if(!file_exists(dirname($logfile))) 5 { ... ......
1 function showlog($content,$filename="filenamelog") 2 { 3 $logfile = 'logs/'.$filename.date('ymd').'.txt'; 4 if(!file_exists(dirname($logfile))) 5 { 6 mkdir(dirname($logfile)); 7 } 8 error_log(date("[y-m-d h:i:s]")."-[".$_server["remote_addr"]."]\t[".$_server['request_uri']."]:".$content."\n", 3,$logfile); 9 } 10 showlog("");