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
|
<?php
|
||||||
// ensure the file exists before attempting to read from it
|
// ensure the file exists before attempting to read from it
|
||||||
$myfile = fopen("posts.txt", "a");
|
if (!file_exists("posts.txt")) {
|
||||||
fclose($myfile);
|
$myfile = fopen("posts.txt", "a");
|
||||||
|
fclose($myfile);
|
||||||
|
}
|
||||||
|
|
||||||
// show content
|
// show content
|
||||||
$myfile = fopen("posts.txt", "r") or die("Unable to open file!");
|
$myfile = fopen("posts.txt", "r") or die("Unable to open file!");
|
||||||
|
|
Reference in a new issue