« Wiltshire Train - can YOU come on 5th March? | Main | Apache httpd , browser, MySQL and MySQL client downloads »

February 27, 2007

PHP fread - truncated data

Note that PHP's fread function returns the number of bytes you request as the second parameter ...OR the number of remaining bytes if it's less than the number you give ... or 8192 bytes, even if there's more than that available and you've requested more.

I got caught out by this one earlier today ... felt that it was useful (re)minder to post it up here.

If you need to read more that 8k into a variable:

while ($info = fread($fh,8192)) {
$fullstuff .= $info;
}

Posted by gje at February 27, 2007 03:21 PM

Comments

Well House Consultants Ltd. Copyright 2010