php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35136 cute featue
Submitted: 2005-11-07 10:38 UTC Modified: 2005-11-07 15:28 UTC
From: dsp at tdcspace dot dk Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 4.4.1 OS: w98
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dsp at tdcspace dot dk
New email:
PHP Version: OS:

 

 [2005-11-07 10:38 UTC] dsp at tdcspace dot dk
Description:
------------
I really thought that the feof() was TRUE when the logical file pointer is a EOF.

but no ! 
we need to do fread() and get an empty record before the feof() reports TRUE.

sunday is the last day in a week and thus end-of-week - and so is the last byte a the file is also EOF.

but the way feof() works - is says - it must wait until monday - before it can find out !


Reproduce code:
---------------
// open and read binary file with 128 byte records

$h = fopen("phpbugs.dat", "rb");

while(!feof($h)) {
  $rec = fread($h, 128);
  if ($strlen($rec) == 0) break; // should not be needed
  }

close($h);


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-11-07 15:28 UTC] sniper@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 [2021-06-22 06:13 UTC] ask dot question at wp dot pl
For me, the feof() also works badly.

   while($max && !feof($src))
   {
      $l=$max>0x100000 ? 0x100000 : $max;
      $s=fread($src,$l);
      if($s===false || $s==='') return 1;
      if(fwrite($dst,$s)!==strlen($s)) return 2;
      if(strlen($s)!==$l) break;
      $max-=$l;
   }

In this code the "$str===false || $str===''" should be not reachable without file problem but it is reachable on Linux. WHY??? 

If the function (feof) works correctly (IMO it doesn't work correctly due to manual definition) - HOW TO CHECK WHY I CANNOT READ FILE? Because of permisions,  or file delete OR real end of file? 

PHP 7.4, Linux. I believe there is real problem in feof implementation in PHP.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Sep 18 02:03:38 2021 UTC