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);

当文件不存在时,file_put_content是否会创建文件test.html?

是。

根据php文档:

如果文件名不存在,则创建该文件。