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 相关文章推荐
一个简单计数器的源代码
Oct 09 PHP
php 多线程上下文中安全写文件实现代码
Dec 28 PHP
php 魔术函数使用说明
Feb 21 PHP
thinkphp文件引用与分支结构用法实例
Nov 26 PHP
php列出mysql表所有行和列的方法
Mar 13 PHP
php序列化函数serialize() 和 unserialize() 与原生函数对比
May 08 PHP
如何使用PHP Embed SAPI实现Opcodes查看器
Nov 10 PHP
windows server 2008/2012安装php iis7 mysql环境搭建教程
Jun 30 PHP
PHP实现多关键字加亮功能
Oct 21 PHP
利用PHP判断是手机移动端还是PC端访问的函数示例
Dec 14 PHP
PHP5中使用mysqli的prepare操作数据库的介绍
Mar 18 PHP
PHP 实现base64编码文件上传出现问题详解
Sep 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
php中Smarty模板初体验
2011/08/08 PHP
CI框架(CodeIgniter)实现的数据库增删改查操作总结
2018/05/23 PHP
PHP PDOStatement::getAttribute讲解
2019/02/01 PHP
js中将具有数字属性名的对象转换为数组
2011/03/06 Javascript
html的DOM中document对象images集合用法实例
2015/01/21 Javascript
JavaScript SweetAlert插件实现超酷消息警告框
2016/01/28 Javascript
echarts实现词云自定义形状的示例代码
2019/02/20 Javascript
vue控制多行文字展开收起的实现示例
2019/10/11 Javascript
微信小程序添加插屏广告并设置显示频率(一天一次)
2019/12/06 Javascript
详解在Python的Django框架中创建模板库的方法
2015/07/20 Python
使用PyV8在Python爬虫中执行js代码
2017/02/16 Python
python出现&quot;IndentationError: unexpected indent&quot;错误解决办法
2017/10/15 Python
神经网络理论基础及Python实现详解
2017/12/15 Python
Python实现按照指定要求逆序输出一个数字的方法
2018/04/19 Python
Python获取航线信息并且制作成图的讲解
2019/01/03 Python
使用Python控制摄像头拍照并发邮件
2019/04/23 Python
django框架面向对象ORM模型继承用法实例分析
2019/07/29 Python
wxPython+Matplotlib绘制折线图表
2019/11/19 Python
巴黎欧莱雅法国官网:L’Oreal Paris
2019/04/30 全球购物
免税水晶:Duty Free Crystal
2019/05/13 全球购物
使用索引有什么好处
2016/07/27 面试题
中年人生感言
2014/02/04 职场文书
《雷雨》教学反思
2014/02/20 职场文书
群众路线教育实践活动心得体会
2014/03/07 职场文书
保护环境倡议书100字
2014/05/19 职场文书
群众路线教育实践活动个人对照检查材料
2014/09/22 职场文书
医学专业大学生职业生涯规划书
2014/10/25 职场文书
质监局领导班子践行群众路线整改方案
2014/10/26 职场文书
2014年工程部工作总结
2014/11/25 职场文书
教育实习指导教师评语
2014/12/31 职场文书
领导干部失职检讨书
2015/05/05 职场文书
2016年第二十届“母亲节暨幸福工程救助贫困母亲活动日”活动总结
2016/04/06 职场文书
解读MySQL的客户端和服务端协议
2021/05/10 MySQL
Python MNIST手写体识别详解与试练
2021/11/07 Python
奥特曼十大神器:奥特手镯在榜,第一是贝利亚的神器
2022/03/18 日漫
python实现学员管理系统(面向对象版)
2022/06/05 Python