note 31994 rejected from function.bzread by jsheets

From: Date: Mon, 12 May 2003 14:00:50 +0000
Subject: note 31994 rejected from function.bzread by jsheets
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-47873@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««&#366;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); ?>

« previous php.notes (#47873) next »