| how to check file is there or not if there prints it is
ther ,if not create a file |
|
|
| <?php |
|
| $filename ='file.txt'; |
or images/applie.jpg |
| echo file_exists($filename); |
prints 1 if file is there , if fileis not there it prints 0 like a
boolean |
| ?> |
asssign the file txt to file nam e variable |
|
|
| <?php |
|
| $filename ='file.txt'; |
file.txt assigns to filename variable |
| if (file_exists($filename){ |
if file exists means 1, it prints file is exists |
| echo'file already exists!'; |
if file is not there |
| }else{ |
it create the file |
| $file = fopen($filename, 'w'); |
file is created, and write action is going to take |
| fwrite($file, 'file is now
created'); |
write the data to that file |
| fclose($file); |
close the file |
| echo 'file is now created and
written'; |
print file is now created and written |
| } |
|
?>
| how to check file is there or not if there prints it is ther ,if
not create a file |
|
|
|
|
|
file name assigned |
| how to prints boolean values if file is
there |
file_exists |
|
|
|
|
| how to check
the file is threr or not, if not there how to create |
|
|
| how to checkfile is there or not |
file_exists |
|
echo |
|
if else |
|
fopen |
| how to create a file if it is not there |
fwrite |
|
fclose |
|
echo |
|
|
No comments:
Post a Comment