File_put_content create file if it does 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 a test.html file if the file does not exist?

+4
source share
1 answer

Yes.

according to php documentation :

If the file name does not exist, the file is created.

+14
source

Source: https://habr.com/ru/post/1537876/


All Articles