建立文件日志方法

首先在项目目录建一个777文件

AutoRunLog.txt

调用openLog方法传入想记录的数据

public function openLog($msg){
   $myfile = fopen("AutoRunLog.txt", "a") or die("Unable to open file!");
   $txt = date("Y-m-d H:i:s",time())."   ".$msg."\n";
   fwrite($myfile, $txt);
   fclose($myfile);
}
最终展示结果
2018-10-12 16:41:07   $msg
2018-10-12 16:41:07   $msg


博客
请先登录后发表评论
  • 最新评论
  • 总共0条评论