首先在项目目录建一个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
本文为王思彤原创文章,转载无需和我联系,但请注明来自王思彤博客wangsitong.com