note 17029 rejected from function.fread by zak

From: Date: Thu, 22 Nov 2001 17:43:28 +0000
Subject: note 17029 rejected from function.fread by zak
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-21173@lists.php.net to get a copy of this message
Seems like the strings returned from fread always have the length "number of characters to read". Try this on your favourite file: clearstatcache (); $FileHandle = fopen ($FileNameAndPath, "rb"); $b = 0; while ($Block = fread ($FileHandle, 8192)) { $b += strlen ($Block); } print "file size: ".filesize ($FileNameAndPath)."<br>"; print "read: $b<br>"; fclose ($FileHandle); On my W2K the two numbers will differ, the number of bytes read always being a multiple of 8192. You can also look at the strlen of each block that is read - you'd expect the last one usually *not* to have a size of 8192, but it does. Is this to be considered a bug or a feature? Steve

« previous php.notes (#21173) next »