bzread
(PHP 4 >= 4.0.4, PHP 5, PHP 7, PHP 8)
bzread — bzip2 檔案二進制安全地讀取
說明
bzread(resource
$bz, int $length = 1024): string|falsebzread() 從指定的 bzip2 檔案指針中讀取數據。
讀取到 length(未經壓縮的長度)個位元組,或者到檔案尾,取決於先到哪個。
參數
-
bz -
檔案指針。它必須是有效的並且指向 bzopen() 成功打開的檔案。
-
length -
如果沒有提供, bzread() 一次會讀入 1024 個位元組(未經壓縮的長度)。 一次最大可讀入 8192 個未壓縮的位元組。
返回值
返回解壓的數據,在錯誤時返回 false。
範例
示例 #1 bzread() 範例
<?php
$file = "/tmp/foo.bz2";
$bz = bzopen($file, "r") or die("Couldn't open $file");
$decompressed_file = '';
while (!feof($bz)) {
$decompressed_file .= bzread($bz, 4096);
}
bzclose($bz);
echo "The contents of $file are: <br />\n";
echo $decompressed_file;
?>