PHP Velho Oeste 2024

bzcompress

(PHP 4 >= 4.0.4, PHP 5, PHP 7)

bzcompress문자열을 bzip2 인코드 데이터로 압축

설명

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

bzcompress()는 주어진 문자열을 압축하고 bzip2 인코딩 데이터로 반환한다.

인수

source

압축할 문자열.

blocksize

압축중에 사용할 blocksize를 설정하고 1에서 9까지의 숫자가 되어야 합니다. 여기서 9는 가장 압축률이 높지만 자원을 더 많이 사용하게 된다. blocksize의 기본값은 4이다.

workfactor

반복이 많은 입력 데이터와 같은 최악의 경우에 압축이 어떻게 동작할지에 대해 제어한다. 이 값은 0부터 250이 될수 있고, 0은 특별한 값으로 기본값입니다.

workfactor에 관계없이, 성생된 출력은 동일합니다.

반환값

압축된 문자열이나, 오류 발생 시 오류 번호.

예제

Example #1 데이터 압축하기

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

참고

add a note add a note

User Contributed Notes 2 notes

up
3
uprz23 at gmail dot com
13 years ago
Comparing gzcompress/gzuncompress and bzcompress/bzdecompress, the bz combo is about 5x slower than gz.
up
3
diego a messenger do dsemmler do de
15 years ago
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
To Top