When I am using bzopen
, do I need to bzwrite()
already compressed by a bzcompress()
string or is it being compressed automatically while writing?
Asked
Active
Viewed 1,368 times
1 Answers
2
Judging by Example #1 on the manual page of bzwrite
(quoting) :
<?php
$str = "uncompressed data";
$bz = bzopen("/tmp/foo.bz2", "w");
bzwrite($bz, $str, strlen($str));
bzclose($bz);
?>
I would say there is no need to compress data yourself with bzcompress
before using bzwrite
.
Also, executing this portion of code will create a file with content that looks like this :
$ cat /tmp/foo.bz2
BZh91AY&SY7�w�@.� 1�&2��� q�o
|]��B@���`
Doesn't look like "uncompressed data
" -- and looks like some bzip2-compressed data ;-)

Pascal MARTIN
- 395,085
- 80
- 655
- 663
-
I saw this example, but if it's so where can you choose compress level? and why does it needs to be external bzcompress() function? – Rob Mar 23 '10 at 21:13
-
1the external `bzcompress()` function exists so you can compress data without sending it to a file *(you might want to send it to the browser, for instance, or store it in a database)* ;;; no idea about how to set the compression level -- sorry. – Pascal MARTIN Mar 23 '10 at 21:16