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

search for in the

gzpassthru> <gzinflate
Last updated: Fri, 13 Nov 2009

view this page in

gzopen

(PHP 4, PHP 5)

gzopenBir gzipli dosya açar

Açıklama

resource gzopen ( string $dosyaismi , string $kip [, int $include_path_kullan = 0 ] )

Okuma veya yazma amacıyla bir gzipli (.gz) dosya açar.

gzopen() işlevi henüz sıkıştırılmamış dosyaları okumak için açmakta da kullanılabilir. Bu durumda gzread(), sıkıştırmasız dosyayı doğrudan okuyacaktır.

Değiştirgeler

dosyaismi

Gzipli dosyanın ismi.

kip

fopen() işlevindeki gibi (rb veya wb) olmakla birlikte ayrıca bir sıkıştırma seviyesiyle (wb9 gibi) birlikte bir strateji de belirtilebilir: wb6f örneğindeki gibi süzgeçli veri için f; wb1h örneğindeki gibi sadece Huffman sıkıştırması için h. (Bu strateji değiştirgeleri hakkında daha ayrıntılı bilgi için zlib.h dosyasındaki deflateInit2 açıklamasına bakınız.)

include_path_kullan

Bu isteğe bağlı değiştirgeye 1 belirtirseniz dosya ayrıca include_path yönergesinde belirtilen yolarda da aranır.

Dönen Değerler

Açılan dosyaya bir dosya tanıtıcısı döndürür. Bu dosya tanıtıcısını kullanarak, (şeffaf olarak) sıkıştırılmış dosyadan herşeyi sıkıştırılmamış olarak okuyabilir ve dosyaya herşeyi sıkıştırılmış olarak yazabilirsiniz.

Açma işlemi başarısız olursa işlev FALSE döndürür.

Örnekler

Örnek 1 - gzopen() örneği

<?php
$dt 
gzopen("/tmp/dosya.gz""r");
?>

Ayrıca Bakınız

  • gzclose() - Bir açık gzipli dosya tanıtıcısını kapar



gzpassthru> <gzinflate
Last updated: Fri, 13 Nov 2009
 
add a note add a note User Contributed Notes
gzopen
plasma
06-Sep-2008 03:06
This worked unstable for me under high load (50+ files per second):

<?php
    $gz
= gzopen ( $file, 'w9' );
   
gzwrite ( $gz, $content );
   
gzclose ( $gz );
?>

The following works fine:

<?php
    $f
= fopen ( $file, 'w' );
   
fwrite ( $f, gzcompress ( $content, 9 ) );
   
fclose ( $f );
?>
katzlbtjunk at hotmail dot com
23-Apr-2008 07:15
WARNING gzopen and gzread have a major disadvantage. They makes NO checksum and NO length verification of the gzipped data and discard this valuable information. This should be documented here.
rob at digital-crocus dot com
01-Jun-2005 12:28
dtorop932 at hotmail dot com's comments, according to my tests, is incorrect. That code wishes to download the entire file before parsing, which is inconvinient. The wget method works though.
pentek_imre at mailbox dot hu
29-Jan-2005 06:36
Be aware that when opening a remote file on a http server the gzopen will return by default false after 120 seconds waiting to any answer.
dtorop932 at hotmail dot com
21-Oct-2004 07:04
RE dubious's comment: "Being able to read gzip streams from ftp and http is near the top of my personal wishlist at the moment..."

One way to read a gzip stream over http is to daisychain stream wrappers, e.g.:

<?
$fp
= fopen("compress.zlib://http://some.website.org/example.gz", "r");
?>
-delete-this-part-dubious at 2xtreme dot net
03-Jan-2002 03:22
"On the fly" gunzipping actually DOES seem to work - it just appears that only LOCAL streams/files (including php://stdin) can be accessed for some reason.  I THINK (but have not yet tested) that you could similarly gzopen "php://stdout" and pass a stream of gzipped data to the browser (when run from a web page) or console (when run standalone) through there.

I HAVE tested scripts from the command line like:

wget -q -O- ftp://some.host.net/pub/some_gzip_file.gz | php gunzip_stuff.php

where gunzip_stuff.php would be a script that gzopened "php://stdin" and did gzgets from that stream, and it seems to work fine, but that obviously doesn't help someone wanting to grab gzipped streams from remote sites from a web-based script.

Being able to read gzip streams from ftp and http is near the top of my personal wishlist at the moment...

gzpassthru> <gzinflate
Last updated: Fri, 13 Nov 2009
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites