简体   繁体   English

file_put_content如果不存在则创建文件?

[英]file_put_content create file if not exist?

$html = file_get_contents('http://www.test.com);
$file = '/Applications/MAMP/htdocs/test.html';
file_put_contents($file,$html);

Does file_put_content create the file test.html when file doesn't exists? 当文件不存在时,file_put_content是否会创建文件test.html?

yes. 是。

as per php documentation : 根据php文档

If filename does not exist, the file is created. 如果filename不存在,则创建该文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM