downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

gzopen> <gzgetss
[edit] Last updated: Fri, 23 Mar 2012

view this page in

gzinflate

(PHP 4 >= 4.0.4, PHP 5)

gzinflateDeflate sıkıştırmalı bir verinin sıkıştırmasını açar

Açıklama

string gzinflate ( string $veri [, int $uzunluk = 0 ] )

Deflate sıkıştırmalı bir verinin sıkıştırmasını açar.

Değiştirgeler

veri

gzdeflate() tarafından sıkıştırılmış veri.

uzunluk

Kodu çözülecek verinin azami uzunluğu.

Dönen Değerler

Bir hata durumunda FALSE aksi takdirde verinin sıkıştırılmamış halini döndürür.

Sıkıştırılmamış veri uzunluğu isteğe bağlı uzunluk ile belirtilenden veya sıkıştırılmış veri'nin 32768 mislinden uzunsa bu işlev bir hata döndürür.

Örnekler

Örnek 1 - gzinflate() örneği

<?php
$sımsıkı 
gzdeflate('Sıkıştırılacak veri'9);
$normal gzinflate($sımsıkı);
echo 
$normal;
?>

Ayrıca Bakınız



gzopen> <gzgetss
[edit] Last updated: Fri, 23 Mar 2012
 
add a note add a note User Contributed Notes gzinflate
Steven Lustig 05-Nov-2010 09:44
You can use this to uncompress a string from Linux command line gzip by stripping the first 10 bytes:

<?php
$inflatedOutput
= gzinflate(substr($output, 10, -8));
?>
vitall at ua dot fm 09-Sep-2009 05:10
The correct function for gzip and chunked data particularly when you get "Content-Encoding: gzip" and "Transfer-Encoding: chunked" headers:

<?php
function decode_gzip($h,$d,$rn="\r\n"){
if (isset(
$h['Transfer-Encoding'])){
 
$lrn = strlen($rn);
 
$str = '';
 
$ofs=0;
 do{
   
$p = strpos($d,$rn,$ofs);
   
$len = hexdec(substr($d,$ofs,$p-$ofs));
   
$str .= substr($d,$p+$lrn,$len);
    
$ofs = $p+$lrn*2+$len;
 }while (
$d[$ofs]!=='0');
 
$d=$str;
}
if (isset(
$h['Content-Encoding'])) $d = gzinflate(substr($d,10));
return
$d;
}
?>

Enjoy!
John 12-Jun-2008 10:22
And when retrieving mod_deflate gzip'ed content and using gzinflate() to decode the data, be sure to strip the first 11 chars from the retrieved content.

<?php $dec = gzinflate(substr($enc,11)); ?>
patatraboum at free dot fr 24-Aug-2007 10:57
Some gz string strip header and return inflated
It actualy processes some first member of the gz
See rfc1952 at http://www.faqs.org/rfcs/rfc1952.html for more details and improvment as gzdecode

<?php
function gzBody($gzData){
    if(
substr($gzData,0,3)=="\x1f\x8b\x08"){
       
$i=10;
       
$flg=ord(substr($gzData,3,1));
        if(
$flg>0){
            if(
$flg&4){
                list(
$xlen)=unpack('v',substr($gzData,$i,2));
               
$i=$i+2+$xlen;
            }
            if(
$flg&8) $i=strpos($gzData,"\0",$i)+1;
            if(
$flg&16) $i=strpos($gzData,"\0",$i)+1;
            if(
$flg&2) $i=$i+2;
        }
        return
gzinflate(substr($gzData,$i,-8));
    }
    else return
false;
}
?>
spikeles_ at hotmail dot com 01-Nov-2006 08:12
This can be used to inflate streams compressed by the Java class java.util.zip.Deflater but you must strip the first 2 bytes off it. ( much like the above comment )

<?php $result = gzinflate(substr($compressedData, 2)); ?>
boris at gamate dot com 08-Jul-2003 05:49
When retrieving mod_gzip'ed content and using gzinflate() to decode the data, be sure to strip the first 10 chars from the retrieved content.

<?php $dec = gzinflate(substr($enc,10)); ?>

 
show source | credits | stats | sitemap | contact | advertising | mirror sites