Answers for "php create file if not exists"

PHP
1

php create file if not exist

<?php

$file = 'test.txt';

if(!is_file($file)){
    $contents = 'This is a test!';           // Some simple example content.
    file_put_contents($file, $contents);     // Save our content to the file.
}

?>
Posted by: Guest on June-17-2021
5

php check if file exists

if (!file_exists('http://mysite.com/images/thumbnail_1286954822.jpg')) {   
$filefound = '0';                         
}
Posted by: Guest on March-24-2020
0

laravel create new file if not exists

if (!file_exists('somefile.txt')) {
    touch('somefile.txt', strtotime('-1 days'));
}
Posted by: Guest on August-13-2020

Code answers related to "php create file if not exists"

Browse Popular Code Answers by Language