note 59277 added to function.fgets
| From: | kpetersAT-ATmonolithssDEEOHTEEcom at osu1 dot php dot net | Date: | Thu, 01 Dec 2005 13:51:45 +0000 |
| Subject: | note 59277 added to function.fgets | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-99415@lists.php.net to get a copy of this message | ||
It appears that fgets() will return FALSE on EOF (before feof has a chance to read it), so this code
will throw an exception:
while (!feof($fh)) {
$line = fgets($fh);
if ($line === false) {
throw new Exception("File read error");
}
}
----
Manual Page -- http://www.php.net/manual/en/function.fgets.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+59277
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+59277&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+59277&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+59277&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+59277&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+59277&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+59277&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+59277&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+59277&report=yes
Search -- http://master.php.net/manage/user-notes.php