I have a script that runs with each visitor. Each visit writes some information to a file. I first check if the file exists using file_exists, and it if does I write to it using file_put_contents using the LOCK_EX flag. For example:-
$file = "myfile.txt";
if ( file_Exists($file) ) {
file_put_contents($file, "some content", LOCK_EX);
} else {
echo "file does not exist";
}
However, on rare occasions, during high traffic, the file_exist check fails even though the file exists. I'm assuming the file lock is preventing file_exists from checking the file, but I cant find any information that confirms this.
Can anybody corroborate my assumption, or is there another possible reason for the file_exists function to throw false?
Thanks