PHP 增加了对 .ZIP 文件的读取功能


Posted in PHP onOctober 09, 2006

This module uses the functions of the ZZIPlib library by Guido Draheim to transparently read ZIP compressed archives and the files inside them.
这个模块使用 ZZIPlib 库(Guido Draheim)来读取 ZIP 压缩文档和里面的文件

Please note that ZZIPlib only provides a subset of functions provided in a full implementation of the ZIP compression algorithm and can only read ZIP file archives. A normal ZIP utility is needed to create the ZIP file archives read by this library.
请注意:这个库只是ZIP所有扩展功能的一个子集,只能读取 ZIP 文档里面的内容。一个普通的 ZIP 环境需要能创建 ZIP 文档

Zip support in PHP is not enabled by default. You will need to use the --with-zip configuration option when compiling PHP to enable zip support. This module requires ZZIPlib version >= 0.10.6.
PHP 没有默认支持 ZIP,你需要使用 --with-zip 配置编译你的 PHP.这个模块需要 ZZPIlib 版本>=0.10.6

Note: Zip support before PHP 4.0.7 is experimental. This section reflects the Zip extension as it exists in PHP 4.0.7 and later.
注意:zip在 4.0.7之前是测试的。这一章写的是 php4.0.7 和以后版本的东西

Example Usage
This example opens a ZIP file archive, reads each file in the archive and prints out its contents. The test2.php archive used in this example is one of the test archives in the ZZIPlib source distribution.

Example 1. Zip Usage Example

<?php

$zip = zip_open("/tmp/test2.zip");

if ($zip) {

while ($zip_entry = zip_read($zip)) {
echo "Name: " . zip_entry_name($zip_entry) . "\n";
echo "Actual Filesize: " . zip_entry_filesize($zip_entry) . "\n";
echo "Compressed Size: " . zip_entry_compressedsize($zip_entry) . "\n";
echo "Compression Method: " . zip_entry_compressionmethod($zip_entry) . "\n";

if (zip_entry_open($zip, $zip_entry, "r")) {
echo "File Contents:\n";
$buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
echo "$buf\n";

zip_entry_close($zip_entry);
}
echo "\n";

}

zip_close($zip);

}

?> 

PHP 相关文章推荐
使PHP自定义函数返回多个值
Nov 26 PHP
php强制下载类型的实现代码
Apr 21 PHP
简单的php文件上传(实例)
Oct 27 PHP
html静态页面调用php文件的方法
Nov 13 PHP
php定时执行任务设置详解
Feb 06 PHP
PHP SPL标准库中的常用函数介绍
May 11 PHP
php从文件夹随机读取文件的方法
Jun 01 PHP
PHP实现求解最长公共子串问题的方法
Nov 17 PHP
php 删除一维数组中某一个值元素的操作方法
Feb 01 PHP
PHP生成加减算法方式的验证码实例
Mar 12 PHP
PHP的mysqli_sqlstate()函数讲解
Jan 23 PHP
PHP调用全国天气预报数据接口查询天气示例
Feb 20 PHP
如何去掉文章里的 html 语法
Oct 09 #PHP
如何分别全角和半角以避免乱码
Oct 09 #PHP
玩转虚拟域名◎+ .
Oct 09 #PHP
桌面中心(四)数据显示
Oct 09 #PHP
桌面中心(一)创建数据库
Oct 09 #PHP
桌面中心(二)数据库写入
Oct 09 #PHP
桌面中心(三)修改数据库
Oct 09 #PHP
You might like
PHP使用PDO、mysqli扩展实现与数据库交互操作详解
2019/07/20 PHP
PHP 观察者模式深入理解与应用分析
2019/09/25 PHP
PHP pthreads v3在centos7平台下的安装与配置操作方法
2020/02/21 PHP
转自Jquery官方 jQuery1.1.3发布,速度提升800%,体积保持20K
2007/08/19 Javascript
基于jquery的blockui插件显示弹出层
2011/04/14 Javascript
javascript 使用 NodeList需要注意的问题
2013/03/04 Javascript
jquery.post用法之type设置问题
2014/02/24 Javascript
深入浅析JavaScript面向对象和原型函数
2016/02/06 Javascript
全面了解javascript中的错误处理机制
2016/07/18 Javascript
js实现移动端微信页面禁止字体放大
2017/02/16 Javascript
jQuery实现ajax无刷新分页页码控件
2017/02/28 Javascript
JavaScript获取URL参数的方法之一
2017/03/24 Javascript
JS实现的简单表单验证功能示例
2017/10/13 Javascript
vue.js开发实现全局调用的MessageBox组件实例代码
2017/11/22 Javascript
vue 监听键盘回车事件详解 @keyup.enter || @keyup.enter.native
2018/08/25 Javascript
基于vue实现一个禅道主页拖拽效果
2019/05/27 Javascript
vue-cli+iview项目打包上线之后图标不显示问题及解决方法
2019/10/16 Javascript
vue 点击其他区域关闭自定义div操作
2020/07/17 Javascript
vue实现简单全选和反选功能
2020/09/15 Javascript
Vue router安装及使用方法解析
2020/12/02 Vue.js
[48:56]2018DOTA2亚洲邀请赛 3.31 小组赛 A组 VG vs KG
2018/03/31 DOTA
Python找出最小的K个数实例代码
2018/01/04 Python
Python 利用内置set函数对字符串和列表进行去重的方法
2018/06/29 Python
python re正则匹配网页中图片url地址的方法
2018/12/20 Python
Python依赖包整体迁移方法详解
2019/08/15 Python
Python实现PyPDF2处理PDF文件的方法示例
2019/09/25 Python
Django 自动生成api接口文档教程
2019/11/19 Python
Python中flatten( ),matrix.A用法说明
2020/07/05 Python
Visual Studio Code搭建django项目的方法步骤
2020/09/17 Python
马克华菲官方商城:Mark Fairwhale
2016/09/04 全球购物
实体的生命周期
2013/08/31 面试题
大学生标准自荐书
2014/06/15 职场文书
医院病假条怎么写
2015/08/17 职场文书
Golang生成Excel文档的方法步骤
2021/06/09 Golang
浅谈@Value和@Bean的执行顺序问题
2021/06/16 Java/Android
从原生JavaScript到React深入理解
2022/07/23 Javascript