php create file if not exist

Solutions on MaxInterview for php create file if not exist by the best coders in the world

showing results for - "php create file if not exist"
Jonathan
24 Mar 2019
1<?php
2
3$file = 'test.txt';
4
5if(!is_file($file)){
6    $contents = 'This is a test!';           // Some simple example content.
7    file_put_contents($file, $contents);     // Save our content to the file.
8}
9
10?>
11