Ok, I have a file that may or may not exist. If it exists, I want to open it and start reading from it. If it doesn't exist, then I just want to create the file for now (I'll do something with it later). Anyways, this is the code I'm using:
$file_pointer = fopen("$dir/filename", "a+r");
while (!feof ($file_pointer)) {
...do something...
}
Now for some reason, even if the file did not exist and had to be created, the while loop is always executed. I guess my question is, how does PHP create a new file? I thought it just created a file with an EOF character in it but does it put something else in the new file too? That's the only thing I can think of to explain why the while loop is always entered--there's more than just an EOF character in the new file created.
Can someone give me a hand?
Thanks in advance for your help!