note 42130 rejected from function.feof by didou
Note Submitter: mark at newfangled dot com
----
When a fopen() is done on a file that has permissions that are set to
not allow the current process user to read it or the file doesn't exist
it returns false. This is expected. The problem is when feof() is fed
the invalid handle it doesn't return TRUE() thus creating an infinite
loop in the following code example.
<?php
$fp = fopen( 't.txt', 'r' );
while( !feof( $fp ) )
{
print fgets( $fp );
}
fclose( $fp );
?>
feof() would return TRUE to cancel the loop and the script would end.
There would of course be warnings because of the invalid file handle,
but that is expected.
There should be better error handling on the developers part and catch
the invalid file handle, but I would expect the file functions to handle
this situation accordingly.
|