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

search for in the

Zlib 関数> <定義済み定数
[edit] Last updated: Fri, 24 May 2013

view this page in

テンポラリファイルをオープンし、テスト用文字列を書きこみ、 続いて、このファイルの内容を 2 回出力します。

例1 簡単な Zlib の例

<?php

$filename 
tempnam('/tmp''zlibtest') . '.gz';
echo 
"<html>\n<head></head>\n<body>\n<pre>\n";
$s "Only a test, test, test, test, test, test, test, test!\n";

// 最大限の圧縮を指定して書きこみ用にファイルをオープン
$zp gzopen($filename"w9");

// 文字列をファイルに書きこむ
gzwrite($zp$s);

// ファイルを閉じる
gzclose($zp);

// 読みこみ用にファイルをオープン
$zp gzopen($filename"r");

// 3 文字読みこむ
echo gzread($zp3);

// ファイルの終端まで出力して閉じる
gzpassthru($zp);
gzclose($zp);

echo 
"\n";

// ファイルをオープンし、内容を出力する (2回目)
if (readgzfile($filename) != strlen($s)) {
        echo 
"Error with zlib functions!";
}
unlink($filename);
echo 
"</pre>\n</body>\n</html>\n";

?>


add a note add a note User Contributed Notes - [0 notes]
There are no user contributed notes for this page.

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