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 缓存函数代码
Aug 27 PHP
基于Windows下Apache PHP5.3.1安装教程
Jan 08 PHP
一道求$b相对于$a的相对路径的php代码
Aug 08 PHP
php下统计用户在线时间的一种尝试
Aug 26 PHP
php代码中使用换行及(\n或\r\n和br)的应用
Feb 02 PHP
php中设置index.php文件为只读的方法
Feb 06 PHP
浅谈本地WAMP环境的搭建
May 13 PHP
PHP将Excel导入数据库及数据库数据导出至Excel的方法
Jun 24 PHP
修复ShopNC使用QQ 互联时提示100010 错误
Nov 08 PHP
详解PHP中cookie和session的区别及cookie和session用法小结
Jun 12 PHP
PHP序列化操作方法分析
Sep 28 PHP
[原创]php使用strpos判断字符串中数字类型子字符串出错的解决方法
Apr 01 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
基于文本的搜索
2006/10/09 PHP
php桌面中心(三) 修改数据库
2007/03/11 PHP
使用Thinkphp框架开发移动端接口
2015/08/05 PHP
PHP抓取淘宝商品的用户晒单评论+图片+搜索商品列表实例
2016/04/14 PHP
浅谈php中的循环while、do...while、for、foreach四种循环
2016/11/05 PHP
php中的钩子理解及应用实例分析
2019/08/30 PHP
JS中attr和prop属性的区别以及优先选择示例介绍
2014/06/30 Javascript
JavaScript让网页出现渐隐渐显背景颜色的方法
2015/04/21 Javascript
jQuery移动端日期(datedropper)和时间(timedropper)选择器附源码下载
2016/04/19 Javascript
全面解析Javascript无限添加QQ好友原理
2016/06/15 Javascript
jQuery实现的省市县三级联动菜单效果完整实例
2016/08/01 Javascript
vue插件tab选项卡使用小结
2016/10/27 Javascript
使用smartupload组件实现jsp+jdbc上传下载文件实例解析
2017/01/05 Javascript
原生JS实现不断变化的标签
2017/05/22 Javascript
利用node.js制作命令行工具方法教程(一)
2017/06/22 Javascript
提高Node.js性能的应用技巧分享
2017/08/10 Javascript
[js高手之路]设计模式系列课程-发布者,订阅者重构购物车的实例
2017/08/29 Javascript
jQuery zTree 异步加载添加子节点重复问题
2017/11/29 jQuery
JS去除字符串最后的逗号实例分析【四种方法】
2019/06/20 Javascript
react实现复选框全选和反选组件效果
2020/08/25 Javascript
JavaScript中跨域问题的深入理解
2021/03/04 Javascript
[15:35]教你分分钟做大人:天怒法师
2014/10/30 DOTA
linux系统使用python获取cpu信息脚本分享
2014/01/15 Python
深入浅析python定时杀进程
2016/06/06 Python
Python字典中的键映射多个值的方法(列表或者集合)
2018/10/17 Python
python3 实现对图片进行局部切割的方法
2018/12/05 Python
使用Python下载抖音各大V视频的思路详解
2021/02/06 Python
H5页面适配iPhoneX(就是那么简单)
2019/12/02 HTML / CSS
通用求职信范文模板分享
2013/12/27 职场文书
中秋节礼品促销方案
2014/02/02 职场文书
基层干部群众路线教育实践活动个人对照检查材料
2014/09/23 职场文书
2015年党日活动总结范文
2015/03/25 职场文书
小兵张嘎电影观后感
2015/06/03 职场文书
2016学习全国教书育人楷模先进事迹心得体会
2016/01/21 职场文书
儿童诗两首教学反思
2016/02/23 职场文书
MySQL复制问题的三个参数分析
2021/04/07 MySQL