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 相关文章推荐
mysql 全文搜索 技巧
Apr 27 PHP
提高define性能的php扩展hidef的安装和使用
Jun 14 PHP
php设计模式 DAO(数据访问对象模式)
Jun 26 PHP
php strnatcmp()函数的用法总结
Nov 27 PHP
PHP制作万年历
Jan 07 PHP
PHP封装的字符串加密解密函数
Dec 18 PHP
Yii操作数据库实现动态获取表名的方法
Mar 29 PHP
微信自定义分享php代码分析
Nov 24 PHP
Yii2中简单的场景使用介绍
Jun 02 PHP
php微信开发之谷歌测距
Jun 14 PHP
PHP获取当前系统时间的方法小结
Oct 03 PHP
PHP实现的杨辉三角求解算法分析
Mar 11 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多个字符串替换成同一个的解决方法
2013/06/18 PHP
ThinkPHP模板引擎之导入资源文件方法详解
2014/06/18 PHP
ThinkPHP3.1新特性之多数据库操作更加完善
2014/06/19 PHP
php传值赋值和传地址赋值用法实例分析
2015/06/20 PHP
php实现中文转数字
2016/02/18 PHP
jQuery 全选效果实现代码
2009/03/23 Javascript
微博@符号的用户名提示效果。(想@到谁?)
2010/11/05 Javascript
JavaScript中的style.display属性操作
2013/03/27 Javascript
Nodejs实现多人同时在线移动鼠标的小游戏分享
2014/12/06 NodeJs
解析javascript中鼠标滚轮事件
2015/05/26 Javascript
JavaScript多图片上传案例
2015/09/28 Javascript
bootstrapValidator.min.js表单验证插件
2017/02/09 Javascript
angular-cli修改端口号【angular2】
2017/04/19 Javascript
详解使用nvm安装node.js
2017/07/18 Javascript
Vue的elementUI实现自定义主题方法
2018/02/23 Javascript
基于webpack4搭建的react项目框架的方法
2018/06/30 Javascript
JavaScript类数组对象转换为数组对象的方法实例分析
2018/07/24 Javascript
判断iOS、Android以及PC端的示例代码
2018/11/15 Javascript
JS实现随机抽取三人
2019/11/06 Javascript
JSONP解决JS跨域问题的实现
2020/05/25 Javascript
js实现车辆管理系统
2020/08/26 Javascript
[01:22:42]2014 DOTA2华西杯精英邀请赛 5 24 DK VS LGD
2014/05/26 DOTA
讲解Python中fileno()方法的使用
2015/05/24 Python
Python的Asyncore异步Socket模块及实现端口转发的例子
2016/06/14 Python
python 通过可变参数计算n个数的乘积方法
2019/06/13 Python
请介绍一下WSDL的文档结构
2013/03/17 面试题
业务助理岗位职责
2013/11/18 职场文书
党的群众路线教育实践活动心得体会900字
2014/03/07 职场文书
机关党员进社区活动总结
2014/07/05 职场文书
2015年少先队活动总结
2015/03/25 职场文书
七一慰问简报
2015/07/20 职场文书
初中同学会致辞
2015/08/01 职场文书
2019个人年度目标制定攻略!
2019/07/12 职场文书
前端学习——JavaScript原生实现购物车案例
2021/03/31 Javascript
Python基础详解之邮件处理
2021/04/28 Python
使用Vue3+Vant组件实现App搜索历史记录功能(示例代码)
2021/06/09 Vue.js