PHP  
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
search for in the  
<bcompiler_write_headerbzclose>
Last updated: Mon, 16 Jul 2012

VII. Bzip2 压缩函数库

简介

Bzip2 函数用来透明的读写 bzip2 (.bz2) 压缩文件。

需求

此模块使用 Julian Seward 写的 bzip2 库。此模块需要 bzip2/libbzip2 版本 >= 1.0.x。

安装

Bzip2 support in PHP is not enabled by default. You will need to use the --with-bz2[=DIR] configuration option when compiling PHP to enable bzip2 support.

运行时配置

本扩展模块在 php.ini 中未定义任何设置指令。

资源类型

此扩展定义了一个资源类型: 一个文件指针,指向正在被操作的 bz2 文件。

预定义常量

本扩展模块未定义任何常量。

该例子打开一临时文件,并写入一测试字符串,然后打印文件内容。

例子 1. Bzip2 示例

<?php

$filename
= "/tmp/testfile.bz2";
$str = "This is a test string.\n";

// 打开写入文件
$bz = bzopen($filename, "w");

// 写入字符串到文件
bzwrite($bz, $str);

// 关闭文件
bzclose($bz);

// 打开读取文件
$bz = bzopen($filename, "r");

// 读取 10 个字符
echo bzread($bz, 10);

// 输出直道文件结尾 (或下1024字节) 并关闭它。
echo bzread($bz);

bzclose($bz);

?>
目录
bzclose -- Close a bzip2 file
bzcompress -- Compress a string into bzip2 encoded data
bzdecompress -- Decompresses bzip2 encoded data
bzerrno -- Returns a bzip2 error number
bzerror --  Returns the bzip2 error number and error string in an array
bzerrstr -- Returns a bzip2 error string
bzflush -- Force a write of all buffered data
bzopen -- Opens a bzip2 compressed file
bzread -- Binary safe bzip2 file read
bzwrite -- Binary safe bzip2 file write



<bcompiler_write_headerbzclose>
 Last updated: Mon, 16 Jul 2012
 
Copyright © 2001-2005 The PHP Group
All rights reserved.
This unofficial mirror is operated at: http://manual.phpv.net/
Last updated: Thu Jul 7 19:13:47 2005 CST