note 31994 added to function.bzread
| From: | Pepe at rack1 dot php dot net | Date: | Mon, 12 May 2003 13:42:56 +0000 |
| Subject: | note 31994 added to function.bzread | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-47872@lists.php.net to get a copy of this message | ||
I suppose bzread() has a big bug.
The output is not only the compressed information, but additional the PHP send some
"cache" data.
For example:
<?
$filename = "testfile.bz2";
$str = "Test";
$bz = bzopen($filename, "w");
bzwrite($bz, $str);
bzclose($bz);
$bz = bzopen($filename, "r");
print bzread($bz, filesize($filename));
bzclose($bz);
?>
I get something like this:
"Test( d9x[5 bases««Ů9É/9É/"
This is probably a file size mistake.
[ file size > compressed file size ]
This is working properly:
<?
$filename = "testfile.bz2";
$str = "Test";
$bz = bzopen($filename, "w");
bzwrite($bz, $str);
bzclose($bz);
$f = "";
if (file_exists($filename)) {
$fajlazonosito = fopen($filename,"r") ;
while ($sor = fread($fajlazonosito,1000)) {
$f .= $sor;
}
fclose($fajlazonosito);
}
print bzdecompress($f);
?>
--
http://www.php.net/manual/en/function.bzread.php
http://master.php.net/manage/user-notes.php?action=edit+31994
http://master.php.net/manage/user-notes.php?action=delete+31994
http://master.php.net/manage/user-notes.php?action=reject+31994