使用file_put_contents()函数(写入字符串)
依次调用
fopen(),fwrite(),fclose()函数(写入字符串)*写入数组:
'lws'); $fp = fopen('./log.txt','a+'); fwrite($fp,var_export($arr,true)); fclose($fp);( 如果报以下错,说明php.ini的时区没有设置好,找到'date.timezone'一行,设置 date.timezone = PRC
Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone.
另外,以上两种文件写入的方式,如果文件不存在都会自动创建该文件,可以省去使用
file_exists()函数判断文件是否存在。)
下一篇:使用PHP怎么批量重命名文件