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 array_map array_multisort 高效处理多维数组排序
Jun 11 PHP
PHP读取网页文件内容的实现代码(fopen,curl等)
Jun 23 PHP
php全排列递归算法代码
Oct 09 PHP
PHP If Else(elsefi) 语句
Apr 07 PHP
解析PHPExcel使用的常用说明以及把PHPExcel整合进CI框架的介绍
Jun 24 PHP
基于php中使用excel的简单介绍
Aug 02 PHP
php中explode的负数limit用法分析
Feb 27 PHP
php根据日期或时间戳获取星座信息和生肖等信息
Oct 20 PHP
php生成无限栏目树
Mar 16 PHP
Laravle eloquent 多对多模型关联实例详解
Nov 22 PHP
PHP数组去重的更快实现方式分析
May 09 PHP
Laravel修改验证提示信息为中文的示例
Oct 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
PHP中,文件上传
2006/12/06 PHP
php检测用户是否用手机(Mobile)访问网站的类
2014/01/09 PHP
PHP提示Cannot modify header information - headers already sent by解决方法
2014/09/22 PHP
PHP关键特性之命名空间实例详解
2017/05/06 PHP
Prototype Template对象 学习
2009/07/19 Javascript
jquery 追加tr和删除tr示例代码
2013/09/12 Javascript
jquery实现点击弹出层效果的简单实例
2014/03/03 Javascript
extjs_02_grid显示本地数据、显示跨域数据
2014/06/23 Javascript
jQuery实现跨域iframe接口方法调用
2015/03/14 Javascript
JavaScript实现重置表单(reset)的方法
2015/04/02 Javascript
使用C++为node.js写扩展模块
2015/04/22 Javascript
学习JavaScript设计模式(继承)
2015/11/26 Javascript
一些实用性较高的js方法
2016/04/19 Javascript
全面解析Bootstrap中tooltip、popover的使用方法
2016/06/13 Javascript
Three.js基础部分学习
2017/01/08 Javascript
vue--vuex详解
2019/04/15 Javascript
JQuery发送ajax请求时中文乱码问题解决
2019/11/14 jQuery
[36:16]完美世界DOTA2联赛PWL S3 access vs Rebirth 第一场 12.19
2020/12/24 DOTA
Python中下划线的使用方法
2015/03/27 Python
进一步理解Python中的函数编程
2015/04/13 Python
教你用Type Hint提高Python程序开发效率
2016/08/08 Python
Python正则替换字符串函数re.sub用法示例
2017/01/19 Python
python 出现SyntaxError: non-keyword arg after keyword arg错误解决办法
2017/02/14 Python
用Python写一段用户登录的程序代码
2018/04/22 Python
python正则-re的用法详解
2019/07/28 Python
Python 日期区间处理 (本周本月上周上月...)
2019/08/08 Python
Python 3.8 新功能来一波(大部分人都不知道)
2020/03/11 Python
canvas实现滑动验证的实现示例
2020/08/11 HTML / CSS
存储过程和sql语句的优缺点
2014/07/02 面试题
利用promise及参数解构封装ajax请求的方法
2021/03/24 Javascript
工程现场管理求职自荐信
2013/10/02 职场文书
体育运动会广播稿
2014/10/05 职场文书
学校清洁工岗位职责
2015/04/15 职场文书
舞蹈社团活动总结
2015/05/07 职场文书
Python函数中的不定长参数相关知识总结
2021/06/24 Python
Windows Server 2012 R2服务器安装与配置的完整步骤
2022/07/15 Servers