note 31994 added to function.bzread

From: 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««&#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); ?> -- 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

« previous php.notes (#47872) next »