bzcompress

(PHP 4 >= 4.0.4, PHP 5)

bzcompressCompress a string into bzip2 encoded data

Description

mixed bzcompress ( string $source [, int $blocksize = 4 [, int $workfactor = 0 ]] )

bzcompress() compresses the given string and returns it as bzip2 encoded data.

Parameters

source

The string to compress.

blocksize

Specifies the blocksize used during compression and should be a number from 1 to 9 with 9 giving the best compression, but using more resources to do so.

workfactor

Controls how the compression phase behaves when presented with worst case, highly repetitive, input data. The value can be between 0 and 250 with 0 being a special case.

Regardless of the workfactor, the generated output is the same.

Return Values

The compressed string, or an error number if an error occurred.

Examples

Example #1 Compressing data

<?php
$str 
"sample data";
$bzstr bzcompress($str9);
echo 
$bzstr;
?>

See Also

Коментарии

The blocksize parameter tells bzip to use 100 000 Byte * blocksize blocks to compress the string. In the example above we can see the output size and time needed of bz[2] to bz[9] are nearly the same, because there ware just 189 058 Byte of data to compress and in this case bz[2] to bz[9] means "compress all data et once".
So we may notice a bigger difference in speed and compression rate with bigger files.

the workfactor parameter sets, how fast bzip switches in the slower fallback algorithm, if the standard algorithm gets problems with much repetitive data. 0 means, bzip uses the default value of 30. This option is recommend.

For more information about the parameter look at http://www.bzip.org/1.0.3/html/low-level.html#bzcompress-init
2009-04-24 06:01:49
http://php5.kiev.ua/manual/ru/function.bzcompress.html
Comparing gzcompress/gzuncompress and bzcompress/bzdecompress, the bz combo is about 5x slower than gz.
2010-06-24 03:52:12
http://php5.kiev.ua/manual/ru/function.bzcompress.html

    Поддержать сайт на родительском проекте КГБ