Note Submitter:

----

Please note that this function "returns TRUE if [...] an error occurs". I don't quite understand why it does, but it means you must check every file pointer before using feof() inside a loop.

$fp = fopen($filename, 'r');
while (!feof($fp)) {
// ...
}

If the file doesn't exist, $fp, won't be a valid resource but feof() will retrun TRUE nonetheless, which means you will be caught in an endless loop.

$fp = fopen($filename, 'r');
if (!is_resource($fp)) {
// ...
} else {
while (!feof($fp)) {
// ...
}
}

Very annoying.