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 相关文章推荐
第十三节--对象串行化
Nov 16 PHP
PHP中fwrite与file_put_contents性能测试代码
Aug 02 PHP
PHP文件上传判断file是否己选择上传文件的方法
Nov 10 PHP
ThinkPHP内置jsonRPC的缺陷分析
Dec 18 PHP
php带抄送和密件抄送的邮件发送方法
Mar 20 PHP
PHP stream_context_create()函数的使用示例
May 12 PHP
基于thinkPHP框架实现留言板的方法
Oct 17 PHP
PHP实现的统计数据功能详解
Dec 06 PHP
PHP使用栈解决约瑟夫环问题算法示例
Aug 27 PHP
PHP删除数组中指定值的元素常用方法实例分析【4种方法】
Aug 21 PHP
PHP进阶学习之类的自动加载机制原理分析
Jun 18 PHP
yii2.0框架多模型操作示例【添加/修改/删除】
Apr 13 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
如何让搜索引擎抓取AJAX内容解决方案
2014/08/25 PHP
PHP aes (ecb)解密后乱码问题
2015/06/22 PHP
php rsa 加密,解密,签名,验签详解
2016/12/06 PHP
PHP正则匹配反斜杠'\'和美元'$'的方法
2017/02/08 PHP
PHP5.6读写excel表格文件操作示例
2019/02/26 PHP
prototype Element学习笔记(Element篇三)
2008/10/26 Javascript
Javascript 中文字符串处理额外注意事项
2009/11/15 Javascript
IE JS无提示关闭窗口不提示的方法
2010/04/29 Javascript
idTabs基于JQuery的根据URL参数选择Tab插件
2012/04/11 Javascript
jquery中插件实现自动添加用户的具体代码
2013/11/15 Javascript
jQuery 删除/替换DOM元素的几种方式
2014/05/20 Javascript
Javascript中浮点数相乘的一个解决方法
2014/06/03 Javascript
JavaScript中的console.dir()函数介绍
2014/12/29 Javascript
javascript结合CSS实现苹果开关按钮特效
2015/04/07 Javascript
JavaScript实现Flash炫光波动特效
2015/05/14 Javascript
java必学必会之static关键字
2015/12/03 Javascript
jquery中object对象循环遍历的方法
2015/12/18 Javascript
微信小程序 设置启动页面的两种方法
2017/03/09 Javascript
Bootstrap实现各种进度条样式详解
2017/04/13 Javascript
JavaScript实现多重继承的方法分析
2018/01/09 Javascript
在移动端使用vue-router和keep-alive的方法示例
2018/12/02 Javascript
Vue前端项目部署IIS的实现
2020/01/06 Javascript
vue中实现回车键登录功能
2020/02/19 Javascript
ElementUI中el-tree节点的操作的实现
2020/02/27 Javascript
小程序实现多个选项卡切换
2020/06/19 Javascript
基于Vue.js+Nuxt开发自定义弹出层组件
2020/10/09 Javascript
Python科学计算之NumPy入门教程
2017/01/15 Python
Python面向对象之反射/自省机制实例分析
2018/08/24 Python
将python2.7添加进64位系统的注册表方式
2019/11/20 Python
基于TensorFlow常量、序列以及随机值生成实例
2020/01/04 Python
欧舒丹美国官网:L’Occitane美国
2018/02/23 全球购物
葡萄牙航空官方网站:TAP Air Portugal
2019/10/31 全球购物
中东最大的在线宠物店:Dubai Pet Food
2020/06/11 全球购物
医学院校毕业生自荐信范文
2014/01/01 职场文书
房屋租赁合同补充协议
2014/10/11 职场文书
MySQL sql_mode修改不生效的原因及解决
2021/05/07 MySQL