Home >Backend Development >PHP Tutorial >php writes to txt file

php writes to txt file

WBOY
WBOYOriginal
2016-07-29 09:07:387561browse

<code><span>$data</span> = <span>"\r\n"</span>.<span>"12332323"</span>;  <span>//</span><span>"\r\n"</span>为txt文件的换行,引用时只能用双引号
<span>$rs</span> = file_put_contents(<span>'go_pdm_log.txt'</span>, <span>$data</span>, <span>FILE_APPEND</span>);</code>

<code>使用file_put_contents(filename, data , flags)直接将文本写入

  fileaname    必选        写入数据的目录加文件名
  data         必选        写入的数据
  flags        可选        1.FILE_APPEND 追加形式写入文件
                          2.LOCK_EX     对文件上锁
</code>

file_put_contents is equivalent to calling fopen(), fwrite() and fclose() in sequence.

').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above introduces how to write txt files in PHP, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn