bzcompress

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

bzcompressVerilen dizgiyi bzip2 kodlamalı olarak sıkıştırır

Açıklama

bzcompress(string $veri, int $blokboyu = 4, int $katsayı = 0): string|int

bzcompress() verilen dizgiyi bzip2 türünde sıkıştırır ve bzip2 kodlu veri olarak döndürür.

Bağımsız Değişkenler

veri

Sıkıştırılacak dizge.

blokboyu

Sıkıştırma esnasında kullanılacak blok boyu belirtilir. Bu değer 1 ile 9 arasında olmalıdır. 9 değeri en iyi sıkıştırmayı sağlamakla birlikte daha fazla özkaynak kullanır.

katsayı

Bu değer verilen sıkıştırma aşamasının en kötü senaryo durumunda nasıl davranacağını belirtir. (Sık tekrarlı, asimetrik) Bu değer 0 ile 250 arasında değişir. 0 özel bir durumdur.

katsayı değerinden bağımsız olarak, üretilen çıktı aynı olur.

Dönen Değerler

Bir hata oluşmuşsa hata numarası ile, oluşmamışsa sıkıştırılmış dizge ile döner.

Örnekler

Örnek 1 - Veri sıkıştırma

<?php
$bilgi
= "örnek bilgi";
$bzbilgi = bzcompress($bilgi, 9);
echo
$bzbilgi;
?>

Ayrıca Bakınız

add a note

User Contributed Notes 2 notes

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