#3515 [Opn]: fread() just read a few bytes
| From: | hholzgra@php.net | Date: | Tue, 01 Oct 2002 20:06:56 +0000 |
| Subject: | #3515 [Opn]: fread() just read a few bytes | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969348929@lists.php.net to get a copy of this message | ||
ID: 3515
Updated by: hholzgra@php.net
Reported By: bjarne.ingelsson@enator.se
Status: Open
-Bug Type: Misbehaving function
+Bug Type: Documentation problem
Operating System: WinNT4 SP6
PHP Version: 3.0.14
New Comment:
documentation should tell that fread may return early due to signal or
other cause of interrupt, should give example using feof() ...
Previous Comments:
------------------------------------------------------------------------
[2000-02-17 09:15:02] bjarne.ingelsson@enator.se
// PHP4b3 problem!
// This version is not available in the dropdown...
fread() doesn't return the correct number of bytes in Win32
environment.
For some reason it just reads the first 33 bytes (in my example,
depends on the file to be read).
$sourcefile = "./aniclick.gif";
$fd = fopen($sourcefile, "r");
$contents = fread($fd, filesize($sourcefile));
$encoded = chunk_split(base64_encode($contents));
fclose($fd);
echo "FileSize: ". filesize($sourcefile)."<BR>
Read: ".strlen($contents). "<BR>
Encoded: ".strlen($encoded). "<BR>
Ratio: ". number_format((strlen($encoded) / strlen($contents)), 2).
"<BR>";
The code above give the following result:
FileSize: 19910
Read: 33
Encoded: 46
Ratio: 1.39
/Bjarne
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=3515&edit=1