note 13408 deleted from function.fgets by sniper
| From: | sniper@php.net | Date: | Sat, 08 Feb 2003 20:09:14 +0000 |
| Subject: | note 13408 deleted from function.fgets by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-43657@lists.php.net to get a copy of this message | ||
It would appear that feof will not return true immediately after a file has been opened, but only
after a read attempt has been made. So Example 1 here will always return an empty buffer on the last
pass of the loop. The correct syntax is:
$fd = fopen("/tmp/inputfile.txt", "r");
$buffer = fgets($fd, 4096);
while (!feof($fd))
{
echo $buffer;
$buffer = fgets($fd, 4096);
}
fclose($fd);