bzread Binary safe bzip2 file read


bzread

(PHP 4 >= 4.0.4, PHP 5)

bzreadBinary safe bzip2 file read

说明

string bzread ( resource $bz [, int $length = 1024 ] )

bzread() reads from the given bzip2 file pointer.

Reading stops when length (uncompressed) bytes have been read or EOF is reached, whichever comes first.

参数

bz

The file pointer. It must be valid and must point to a file successfully opened by bzopen().

length

If not specified, bzread() will read 1024 (uncompressed) bytes at a time. A maximum of 8192 uncompressed bytes will be read at a time.

返回值

Returns the uncompressed data, or FALSE on error.

范例

Example #1 bzread() example

<?php

$file 
"/tmp/foo.bz2";
$bz bzopen($file"r") or die("Couldn't open $file");

$decompressed_file '';
while (!
feof($bz)) {
  
$decompressed_file .= bzread($bz4096);
}
bzclose($bz);

echo 
"The contents of $file are: <br /> ";
echo 
$decompressed_file;

?>

参见

  • bzwrite() - Binary safe bzip2 file write
  • feof() - 测试文件指针是否到了文件结束的位置
  • bzopen() - Opens a bzip2 compressed file


«  bzopen
» bzwrite
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3