PHP将字符串写入txt文件

1     function writelog($str)
2     {
3         $open=fopen("e:log.txt","a" );
4         fwrite($open,$str);
5         fclose($open);
6     }
View Code

1. 使用 fopen($filePath, $type)  来打开文件,

   $filePah--保存文件的路径;$type--打开文件的方式,更多fopen()的信息http://www.w3school.com.cn/php/func_filesystem_fopen.asp

2.使用 fwrit();写入文件

3.最后使用fclose();关闭文件  

原文地址:https://www.cnblogs.com/tommy-huang/p/5132662.html