if statement for checking if posts file exists
This commit is contained in:
parent
f50b2817e3
commit
a492989894
1 changed files with 4 additions and 2 deletions
|
@ -109,8 +109,10 @@
|
|||
|
||||
<?php
|
||||
// ensure the file exists before attempting to read from it
|
||||
$myfile = fopen("posts.txt", "a");
|
||||
fclose($myfile);
|
||||
if (!file_exists("posts.txt")) {
|
||||
$myfile = fopen("posts.txt", "a");
|
||||
fclose($myfile);
|
||||
}
|
||||
|
||||
// show content
|
||||
$myfile = fopen("posts.txt", "r") or die("Unable to open file!");
|
||||
|
|
Reference in a new issue