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

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

view this page in

gzwrite

(PHP 4 <= 4.2.3)

gzwrite — バイナリセーフな gz ファイル書き込み

説明

int gzwrite ( resource zp, string string [, int length] )

gzwrite()string の内容を与えられた gz ファイルに書き込みます。

パラメータ

zp

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

string

書き込む文字列を指定します。

length

書き込む解凍されたバイト数を指定します。 もし指定された場合、 length バイトのデータが書き込まれたか、 string の終わりに達した時に 書き込みは終了します。

注意: 引数 length が指定された場合、 magic_quotes_runtime 設定オプションは無視されて string から スラッシュが取り除かれなくなることに注意してください。

返り値

与えられた gz ファイルストリームに書き込まれた (解凍された) バイト数を返します。

例 2551. gzwrite() の例

<?php
$string
= 'Some information to compress';
$gz = gzopen('somefile.gz','w9');
gzwrite($gz, $string);
gzclose($gz);
?>

参考

gzread()
gzopen()



add a note add a note User Contributed Notes
gzwrite
Kioob
13-Aug-2003 08:30
This is a short example of use gzwrite function.
<?php
function gzcompressfile($source,$level=false){
  
$dest=$source.'.gz';
  
$mode='wb'.$level;
  
$error=false;
   if(
$fp_out=gzopen($dest,$mode)){
       if(
$fp_in=fopen($source,'rb')){
           while(!
feof($fp_in))
              
gzwrite($fp_out,fread($fp_in,1024*512));
          
fclose($fp_in);
           }
         else
$error=true;
      
gzclose($fp_out);
       }
     else
$error=true;
   if(
$error) return false;
     else return
$dest;
   }
?>

the function gzcompressfile() compress a file 'data.csv' to 'data.csv.gz'. the function return false if error, and the new file name if it's ok.

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