#24627 [Com]: feof always returns false

From: Date: Sat, 12 Jul 2003 23:21:04 +0000
Subject: #24627 [Com]: feof always returns false
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-43829@lists.php.net to get a copy of this message
ID: 24627 Comment by: b_ulrich at t-online dot de Reported By: duerra at yahoo dot com Status: Open Bug Type: Filesystem function related Operating System: XP Pro PHP Version: 4.3.3RC1 New Comment: Your example works correct: while(!feof($open)) { $count++; } must be an endless loop because the filepointer never moves. Maybe you should do an fread($open,1024); inside the while loop. Or what ever you want to count. Previous Comments: ------------------------------------------------------------------------ [2003-07-12 18:07:44] duerra at yahoo dot com Description: ------------ In PHP 4.3.3RC1, feof (Windows) always returns false in the code provided below, and goes into an endless loop. Reproduce code: --------------- $count = 0; if ($handle = opendir("./")) { while (false !== ($file = readdir($handle))) { if(!is_dir($file) AND $file != '.' AND $file !='..' AND $file !='default' AND (strstr($file, ".php") OR strstr($file, ".htm") OR strstr($file, ".txt"))) { if(!$open = fopen($file, "r")) { echo "Could Not Open File"; exit; } while(!feof($open)) { $count++; } fclose($open); } } } echo $count; Expected result: ---------------- 123456 (or another number) Actual result: -------------- Infinite loop once a file is opened (I cut out the test code that I used to verify that it's actually a bug in order to stay within the 20 line limit). ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=24627&edit=1

« previous php.bugs (#43829) next »