Home  >  Article  >  Backend Development  >  file_put_contents跟fwrite读写文件的区别

file_put_contents跟fwrite读写文件的区别

WBOY
WBOYOriginal
2016-06-13 11:32:431016browse

file_put_contents和fwrite读写文件的区别
第一种:

<br />$james=fopen("index.htm","a");<br />fwrite($james,$rose);<br />fclose($james);<br />

第二种:
<br />file_put_contents('index.htm',$rose);<br />

这两种方法读写文件有啥区别吗?第二种一行代码就够了,所以经常用第二种。什么情况下用第一种,什么情况下用第二种?有何利弊?

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