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
php 全局变量范围分析
Aug 07 PHP
php不使用插件导出excel的简单方法
Mar 04 PHP
PHP的MVC模式实现原理分析(一相简单的MVC框架范例)
Apr 29 PHP
PHP Streams(流)详细介绍及使用
May 12 PHP
PHP之将POST数据转化为字符串的实现代码
Nov 03 PHP
ThinkPHP中create()方法自动验证表单信息
Apr 28 PHP
解决php-fpm.service not found问题的办法
Jun 06 PHP
全面解析PHP面向对象的三大特征
Jun 10 PHP
PHP CURL与java http使用方法详解
Jan 26 PHP
php中钩子(hook)的原理与简单应用demo示例
Sep 03 PHP
PHPExcel实现的读取多工作表操作示例
Apr 14 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+jQuery 注册模块开发详解
2014/10/14 PHP
简单谈谈php中的unicode和utf8编码
2015/06/10 PHP
php经典算法集锦
2015/11/14 PHP
smarty的section嵌套循环用法示例
2016/05/28 PHP
PHP实现验证码校验功能
2017/11/16 PHP
PHP基于redis计数器类定义与用法示例
2018/02/08 PHP
PHP的imageTtfText()函数深入详解
2021/03/03 PHP
Jquery ajax不能解析json对象,报Invalid JSON错误的原因和解决方法
2010/03/27 Javascript
javascript内存管理详细解析
2013/11/11 Javascript
制作jquery遮罩层效果导航菜单代码分享
2013/12/25 Javascript
JS中如何判断传过来的JSON数据中是否存在某字段
2014/08/18 Javascript
浏览器环境下JavaScript脚本加载与执行探析之动态脚本与Ajax脚本注入
2016/01/19 Javascript
JS获取html元素的标记名实现方法
2016/10/08 Javascript
nodejs入门教程三:调用内部和外部方法示例
2017/04/24 NodeJs
Vue中定义全局变量与常量的各种方式详解
2017/08/23 Javascript
bootstrap paginator分页插件的两种使用方式实例详解
2017/11/14 Javascript
深入浅出 Vue 系列 -- 数据劫持实现原理
2019/04/23 Javascript
vue移动端实现手机左右滑动入场动画
2020/06/17 Javascript
vue实现标签云效果的方法详解
2019/08/28 Javascript
[46:48]DOTA2上海特级锦标赛A组小组赛#2 Secret VS CDEC第三局
2016/02/25 DOTA
Python 网页解析HTMLParse的实例详解
2017/08/10 Python
Django如何实现内容缓存示例详解
2017/09/24 Python
python线程池(threadpool)模块使用笔记详解
2017/11/17 Python
python生成ppt的方法
2018/06/07 Python
浅谈Pandas Series 和 Numpy array中的相同点
2019/06/28 Python
python下载卫星云图合成gif的方法示例
2020/02/18 Python
如何从csv文件构建Tensorflow的数据集
2020/09/21 Python
魅力惠奢品线上平台:MEI.COM
2016/11/29 全球购物
AE美国鹰日本官方网站: American Eagle Outfitters
2016/12/10 全球购物
澳大利亚家具和家居用品在线:BROSA
2017/11/02 全球购物
新奥尔良珠宝:Mignon Faget
2020/11/23 全球购物
加拿大户外探险购物网站:SAIL
2020/06/27 全球购物
Jdbc数据访问技术面试题
2012/03/30 面试题
教师党员思想汇报
2014/01/06 职场文书
2014年扶贫帮困工作总结
2014/12/09 职场文书
授权委托书
2015/01/28 职场文书