|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-01-25 12:56 UTC] hholzgra@php.net
i asume this not only true for C fread() but also for PHP ? if so -> should be documented as such ... PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 16:00:01 2025 UTC |
here was my code: $f=fopen("./foo","r"); while($c=fgetc($f)){ ... } ...and the 'while' loop was quit long before EOF was reached. After examination, it was quit when a character 0 was read (thus confusion between 0 and EOF.......)Try this code instead: $f = fopen("./foo","r"); while (false !== ($c = fgetc($f))) { ... } As this is really what you want to do ;) The documentation for fgetc() really needs to mention this as most others that might encounter this 0==false do (such as readdir). A documention problem is to do the following to the fgetc docs: a) Add an example that keeps in mind false vs 0 b) Implement the &return.falseproblem; entity.i prefere the while(!feof($f)) { $c=fgetc($f); ... } style ...I have problems with below code too... It stops to read in the middle even for 10 KB files. $fd= fread(fopen("http://something.com/index.php", "r"), 100000000000); if (!($fd)) {echo "Error in loading page. Please try again later.";} $orgfile=Substr($fd,0, 100000000000); echo $orgfile; die;