From:             stephen at mu dot com dot au
Operating system: Linux
PHP version:      4.3.0
PHP Bug Type:     Feature/Change Request
Bug description:  feof($fp) where $fp isn't a valid resource returns false

Short code snippet -

$fp = fopen($filename);
while (!feof($fp)) fread($fp, 1024);

Summary -
fopen() requires 2 arguments, not 1 so it returns NULL (this is correct
behavior).

feof($fp) when $fp = NULL returns false. So when using !feof($fp) as a
loop condition, we get an infinite loop (and 2 error messages per
iteration around the loop).

I suggest that the foef() function be modified to return that foef($fp) is
true, not false, when reporting an error with the file handle resource.
This is on the basis that foef($fp) returning false is a condition for the
program to continue reading from $fp (i.e. the file pointer contains more
data - has not reached the end of file).
-- 
Edit bug report at http://bugs.php.net/?id=22883&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=22883&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=22883&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=22883&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=22883&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=22883&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=22883&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=22883&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=22883&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=22883&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=22883&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=22883&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=22883&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=22883&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=22883&r=gnused

Reply via email to