I have read the comment about feof()
on PHP manual, the answer here on StackOverflow and another answer on StackOverflow.
So I've understood that using feof()
does not mean using a 'crystal ball' to magically know whether there are more characters or lines in a stream, as mentioned second link above. Rather, it is a test that indicates whether an input operation failed or not (in this case, I only care about the input operation of fgetc()
of PHP). So the last character read will still be okay. AND THEN, the feof()
of while(!feof($file_you_read_from))
will still be false simply because the last fgetc()
still succeeded and after one more loop where fgetc()
attempts to read and fail, only then will feof()
be set to true. Am I correct? Did I misunderstand something?