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 之 没有mysql支持时的替代方案
Oct 09 PHP
cache_lite试用
Feb 14 PHP
PHP 上传文件大小限制
Jul 05 PHP
php中函数的形参与实参的问题说明
Sep 01 PHP
php生成固定长度纯数字编码的方法
Jul 09 PHP
[原创]ThinkPHP中SHOW_RUN_TIME不能正常显示运行时间的解决方法
Oct 10 PHP
PHP获取昨天、今天及明天日期的方法
Feb 03 PHP
CI框架简单邮件发送类实例
May 18 PHP
PHP标准类(stdclass)用法示例
Sep 28 PHP
PHP房贷计算器实例代码,等额本息,等额本金
Apr 01 PHP
用Laravel Sms实现laravel短信验证码的发送的实现
Nov 29 PHP
php中错误处理操作实例分析
Aug 23 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
BBS(php &amp; mysql)完整版(二)
2006/10/09 PHP
PHP中对各种加密算法、Hash算法的速度测试对比代码
2014/07/08 PHP
PHP基于回溯算法解决n皇后问题的方法示例
2017/11/07 PHP
PHP PDOStatement::closeCursor讲解
2019/01/30 PHP
PHP安装BCMath扩展的方法
2019/02/13 PHP
游戏人文件夹程序 ver 4.03
2006/07/14 Javascript
juqery 学习之六 CSS--css、位置、宽高
2011/02/11 Javascript
jquery动画4.升级版遮罩效果的图片走廊--带自动运行效果
2012/08/24 Javascript
javascript的offset、client、scroll使用方法详解
2012/12/25 Javascript
Js+Jq获取URL参数的集中方法示例代码
2014/05/20 Javascript
node.js中的fs.chmodSync方法使用说明
2014/12/18 Javascript
js的window.showModalDialog及window.open用法实例分析
2015/01/29 Javascript
javascript常用的方法分享
2015/07/01 Javascript
jquery中live()方法和bind()方法区别分析
2016/06/23 Javascript
浅谈JS中的!=、== 、!==、===的用法和区别
2016/09/24 Javascript
jQuery插件WebUploader实现文件上传
2016/11/07 Javascript
vue.js的安装方法
2017/05/12 Javascript
vue.js选中动态绑定的radio的指定项
2017/06/02 Javascript
详解浏览器缓存和webpack缓存配置
2018/07/06 Javascript
Vue-CLI 3.X 部署项目至生产服务器的方法
2019/03/22 Javascript
在LayUI图片上传中,解决由跨域问题引起的请求接口错误的方法
2019/09/24 Javascript
vue.js的状态管理vuex中store的使用详解
2019/11/08 Javascript
vue-socket.io跨域问题有效解决方法
2020/02/11 Javascript
js实现筛选功能
2020/11/24 Javascript
[48:38]DOTA2亚洲邀请赛 3.31 小组赛 B组 Mineski vs Secret
2018/03/31 DOTA
分享Python字符串关键点
2015/12/13 Python
python批量下载网站马拉松照片的完整步骤
2018/12/05 Python
使用python的pyplot绘制函数实例
2020/02/13 Python
Python基于Tkinter编写crc校验工具
2020/05/06 Python
医院党的群众路线教育实践活动领导班子对照检查材料
2014/09/25 职场文书
党员个人自我剖析材料
2014/10/08 职场文书
以权谋私检举信范文
2015/03/02 职场文书
优秀教师主要事迹材料
2015/11/04 职场文书
经典法律座右铭(50句)
2019/08/15 职场文书
咖啡厅里的创业计划书
2019/08/21 职场文书
Python捕获、播放和保存摄像头视频并提高视频清晰度和对比度
2022/04/14 Python