ID: 21877 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] -Status: Verified +Status: Closed Bug Type: Documentation problem Operating System: * PHP Version: 4CVS-2003-01-25 (stable) Assigned To: hholzgra New Comment:
That's unrelated, read the fread() docs for why. This bug is now closed and will show up in the next manual build, thanks for the report :) I chose not to use feof() as to more clearly demonstrate the 'false problem' and because it just means an extra function call for every character. http://cvs.php.net/cvs.php/phpdoc/en/reference/filesystem/functions/fgetc.xml Previous Comments: ------------------------------------------------------------------------ [2003-06-08 09:01:30] nkist at operamail dot com 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; ------------------------------------------------------------------------ [2003-01-28 13:07:29] [EMAIL PROTECTED] True. How about using feof() in the example and including the falseproblem entity in the docs. ------------------------------------------------------------------------ [2003-01-28 04:11:23] [EMAIL PROTECTED] i prefere the while(!feof($f)) { $c=fgetc($f); ... } style ... ------------------------------------------------------------------------ [2003-01-27 20:29:53] [EMAIL PROTECTED] 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. ------------------------------------------------------------------------ [2003-01-27 19:53:30] gaelx at free dot fr 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.......) ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/21877 -- Edit this bug report at http://bugs.php.net/?id=21877&edit=1 -- PHP Documentation Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
