php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28621 fgets calls always return false if end-of-file has occured earlier
Submitted: 2004-06-03 12:02 UTC Modified: 2004-06-04 15:50 UTC
From: pickett at sumu dot org Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 4.3.7RC1 OS:
Private report: No CVE-ID: None
 [2004-06-03 12:02 UTC] pickett at sumu dot org
Description:
------------
fgets calls will keep returning false if a fd has at some point reached end-of-file, even though the pointer is no longer at EOF.  feof() will also keep returning true.

Using fread() instead of fgets() works, but is inconvenient if you'd like to read just one line at a time.

Reproduce code:
---------------
  $fdw = fopen("test", "w");
  $fdr = fopen("test", "r");

  fputs($fdw, "testing 1..\n");
  var_dump(fgets($fdr, 0xff));
  var_dump(fgets($fdr, 0xff));
  fputs($fdw, "testing 2..\n");
  var_dump(fgets($fdr, 0xff));



Expected result:
----------------
string(12) "testing 1..
"
bool(false)
string(12) "testing 2..
"


Actual result:
--------------
string(12) "testing 1..
"
bool(false)
bool(false)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-06-04 15:50 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

This is to be expected. 
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Aug 10 02:01:24 2020 UTC