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实现的功能是显示8条基色色带
Oct 09 PHP
php 地区分类排序算法
Jul 01 PHP
生成随机字符串和验证码的类的PHP实例
Dec 24 PHP
使用PHP生成二维码的两种方法(带logo图像)
Mar 14 PHP
利用谷歌 Translate API制作自己的翻译脚本
Jun 04 PHP
php使用正则表达式去掉html中的注释方法
Nov 03 PHP
thinkphp分页集成实例
Jul 24 PHP
PHP延迟静态绑定的深入讲解
Apr 02 PHP
PHP实现从PostgreSQL数据库检索数据分页显示及根据条件查找数据示例
Jun 09 PHP
使用Laravel中的查询构造器实现增删改查功能
Sep 03 PHP
php实现的支付宝网页支付功能示例【基于TP5框架】
Sep 16 PHP
PHP如何通过date() 函数格式化显示时间
Nov 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
提升PHP执行速度全攻略(上)
2006/10/09 PHP
Codeigniter框架的更新事务(transaction)BUG及解决方法
2014/07/25 PHP
Win2003+apache+PHP+SqlServer2008 配置生产环境
2014/07/29 PHP
php实现压缩多个CSS与JS文件的方法
2014/11/11 PHP
WordPress中重置文章循环的rewind_posts()函数讲解
2016/01/11 PHP
PHP接入微信H5支付的方法示例
2019/10/28 PHP
JavaScript 事件参考手册
2008/12/24 Javascript
js随机颜色代码的多种实现方式
2013/04/23 Javascript
禁止选中文字兼容IE、Chrome、FF等
2013/09/04 Javascript
php的文件上传入门教程(实例讲解)
2014/04/10 Javascript
实例讲解JavaScript中call、apply、bind方法的异同
2016/09/13 Javascript
Vue的Class与Style绑定的方法
2017/09/01 Javascript
深入理解js 中async 函数的含义和用法
2018/05/13 Javascript
Vue.js组件使用props传递数据的方法
2019/10/19 Javascript
[01:05:32]DOTA2上海特级锦标赛主赛事日 - 3 败者组第三轮#1COL VS Alliance第一局
2016/03/04 DOTA
[03:19]2016国际邀请赛中国区预选赛第四日TOP10镜头集锦
2016/07/01 DOTA
[01:21:36]CHAOS vs Alliacne 2019国际邀请赛小组赛 BO2 第一场 8.15
2019/08/16 DOTA
用Python遍历C盘dll文件的方法
2015/05/06 Python
Python利用BeautifulSoup解析Html的方法示例
2017/07/30 Python
Flask实现图片的上传、下载及展示示例代码
2018/08/03 Python
解决python xlrd无法读取excel文件的问题
2018/12/25 Python
python中的colorlog库使用详解
2019/07/05 Python
python判断自身是否正在运行的方法
2019/08/08 Python
详解如何在cmd命令窗口中搭建简单的python开发环境
2019/08/29 Python
.img/.hdr格式转.nii格式的操作
2020/07/01 Python
Python3使用 GitLab API 进行批量合并分支
2020/10/15 Python
台湾最大银发乐活百货:乐龄网
2018/05/21 全球购物
大学自我鉴定
2013/12/20 职场文书
《神奇的克隆》教学反思
2014/04/10 职场文书
护士实习求职信
2014/06/22 职场文书
小学生春游活动方案
2014/08/20 职场文书
2014年大学生预备党员思想汇报1000字
2014/09/13 职场文书
共青团员自我评价范文
2014/09/14 职场文书
休假证明书
2015/06/24 职场文书
诚实守信主题班会
2015/08/13 职场文书
Java时间工具类Date的常用处理方法
2022/05/25 Java/Android