When I am using bzopen
, do I need to bzwrite()
already compressed by a bzcompress()
string or is it being compressed automatically while writing?
views:
85answers:
1
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
2010-03-23 21:11:33
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
2010-03-23 21:13:49
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
2010-03-23 21:16:23
Yep, you are right about example
Rob
2010-03-23 21:20:32