|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-08-02 10:51 UTC] nikhil dot gupta at in dot ibm dot com
[2007-09-19 14:57 UTC] tzachi at zend dot com
[2007-09-21 06:02 UTC] nikhil dot gupta at in dot ibm dot com
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Nov 04 17:00:01 2025 UTC |
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)