From: nikhil dot gupta at in dot ibm dot com Operating system: Linux, Win32-xp PHP version: 5CVS-2007-08-02 (snap) PHP Bug Type: Filesystem function related Bug description: feof() fails to detect the end of file
Description: ------------ feof() is not able to detect the end of file even when the file pointer is set to EOF using fseek() or any other ways. If we use the sample code similar to that given in the help docs for feof() on php.net: <?php $fh = fopen("file.tmp", "w"); fclose($fh); $fh = fopen("file.tmp", "r"); while(!feof()){ } fclose($fh); unlink("file.tmp"); ?> The code runs to endless loop as feof donot detect the EOF. Reproduce code: --------------- <?php $fh = fopen("file.tmp", "w"); fwrite($fh, "aaa"); fclose($fh); $fh = fopen("file.tmp", "r"); var_dump( ftell($fh) ); var_dump( fseek($fh, 0, SEEK_END) ); var_dump( ftell($fh) ); var_dump( feof($fh) ); fclose($fh); unlink("file.tmp"); ?> Expected result: ---------------- int(0) int(0) int(3) bool(true) Actual result: -------------- int(0) int(0) int(3) bool(false) -- Edit bug report at http://bugs.php.net/?id=42175&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=42175&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=42175&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=42175&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=42175&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=42175&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=42175&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=42175&r=needscript Try newer version: http://bugs.php.net/fix.php?id=42175&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=42175&r=support Expected behavior: http://bugs.php.net/fix.php?id=42175&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=42175&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=42175&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=42175&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=42175&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=42175&r=dst IIS Stability: http://bugs.php.net/fix.php?id=42175&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=42175&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=42175&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=42175&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=42175&r=mysqlcfg