tags:

views:

85

answers:

1

When I am using bzopen, do I need to bzwrite() already compressed by a bzcompress() string or is it being compressed automatically while writing?

A: 

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
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
the 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
Yep, you are right about example
Rob