|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-11-30 18:30 UTC] dsp at tdcspace dot dk
Description:
------------
feof() does not report eof on a zero (0) length file
following code (similar to the ex. in the php manual) does
act like a new record was read - allthouh the file IS at eof.
$handle = @fopen("xxx", "r");
while (!feof($handle)) {
$buffer = fgets($handle, 4096);
echo $buffer;
}
fclose($handle);
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 29 08:00:01 2025 UTC |
I get the same result with this C code: #include <stdlib.h> #include <stdio.h> int main() { FILE *fd; fd = fopen("/tmp/xxx", "r"); while (!feof(fd)) { char buf[100]; fgets(buf, 100, fd); // remove that and you'll get endless cycle printf("read\n"); } fclose(fd); return 0; } (it reads once and stops just after that) Doesn't look like a bug to me. PHP behaves in the same way as the underlying OS.