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: gzread - 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

gzrewind" width="11" height="7"/> <gzputs
Last updated: Mon, 05 Feb 2007

view this page in

gzread

(PHP 4 <= 4.2.3)

gzread — バイナリ対応のgzファイル読み込み

説明

string gzread ( resource zp, int length )

gzread() は、最大 length バイトのデータを zp が指す gz ファイルポインタ から読み込みます。(解凍された) length バイトのデータが読み込まれたか、 EOF に達したとき、読み込みは終了します。

パラメータ

zp

gz ファイルポインタを指定します。これは有効なファイルポインタであり、 かつ、gzopen() によりオープンできたファイルを指している必要があります。

length

読み込むバイト数を指定します。

返り値

読み込まれたデータ

例 2548. gzread() の例

<?php
// gz ファイルの内容を文字列に読み込む
$filename = "/usr/local/something.txt.gz";
$zd = gzopen($filename, "r");
$contents = gzread($zd, 10000);
gzclose($zd);
?>

参考

gzwrite()
gzopen()
gzgets()
gzgetss()
gzfile()
gzpassthru()



add a note add a note User Contributed Notes
gzread
methatron at hotmail dot com
27-Sep-2006 04:33
Be aware that gzread's second parameter - length reffers to the file's uncompressed size, therefore using this code:

<?php
$file_name
= "/usr/local/something.txt.gz";
if(
$file_handle = gzopen($file_name, "r"))
{
  
$contents = gzread($file_handle, filesize($file_name));
  
gzclose($file_name);
}
?>

will probably truncate the content of the file as filesize checks for the file's compressed size.
So either use the actual uncompressed size, if you know it, or use an aribtrary big enough length, as gzreading will stop at the end of the file anyway.

gzrewind" width="11" height="7"/> <gzputs
Last updated: Mon, 05 Feb 2007
 
 
show source | credits | sitemap | contact | advertising | mirror sites