Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
PHP: gzfile - Manual
[go: Go Back, main page]

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

search for in the

gzgetc" width="11" height="7"/> <gzeof
Last updated: Fri, 02 May 2008

view this page in

gzfile

(PHP 4, PHP 5)

gzfile — gzファイル全体を配列に読み込む

説明

array gzfile ( string $filename [, int $use_include_path ] )

ファイルを配列にして返すこと以外は readgzfile() と同じです。

パラメータ

filename

ファイル名を指定します。

use_include_path

もし include_path にあるファイルも検索したい場合、 このオプションパラメータに 1 を設定することができます。

返り値

ファイルを含む配列で、要素毎に 1 行ずつ含んでいます。

例1 gzfile() の例

<?php
$lines 
gzfile('somefile.gz');
foreach (
$lines as $line) {
    echo 
$line;
}
?>



gzgetc" width="11" height="7"/> <gzeof
Last updated: Fri, 02 May 2008
 
add a note add a note User Contributed Notes
gzfile
nb_nonospamm_ at wtal dot de
27-Nov-2005 09:12
In PHP4.4.1 I noticed that gzfile only reads up to 8190 bytes per line. I had a 20K SQL query that was cut into 3 parts - and wondered why the SQL server complained.

Reading an uncompressed file with the file() command works as expected.
The Jedi
28-Jun-2005 10:44
A quicker way to load a gziped file in a string :
<?php
function gzfile_get_contents($filename, $use_include_path = 0)
{
   
//File does not exist
   
if( !@file_exists($filename) )
    {    return
false;    }
   
   
//Read and imploding the array to produce a one line string
  
$data = gzfile($filename, $use_include_path);
  
$data = implode($data);
   return
$data;
}
?>
webmaster at ragnarokonline dot de
14-Jan-2004 04:58
This works similar to gzfile() but it returns the file in a string instead of an array and doesn't write it to stdout compared to readgzfile.

Note: unlike the usual file-functions filesize won't work here, since the length-parameter of gzread refers to the uncompressed length, while filesize returns the size of the compressed file.

<?php
function gzfile_get_contents($filename, $use_include_path = 0) {
   
$file = @gzopen($filename, 'rb', $use_include_path);
    if (
$file) {
       
$data = '';
        while (!
gzeof($file)) {
           
$data .= gzread($file, 1024);
        }
       
gzclose($file);
    }
    return
$data;
}
?>

gzgetc" width="11" height="7"/> <gzeof
Last updated: Fri, 02 May 2008
 
 
show source | credits | sitemap | contact | advertising | mirror sites