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守护进程 加linux命令nohup实现任务每秒执行一次
Jul 04 PHP
用C/C++扩展你的PHP 为你的php增加功能
Sep 06 PHP
深入PHP empty(),isset(),is_null()的实例测试详解
Jun 06 PHP
探讨PHP调用时间格式的参数详解
Jun 06 PHP
探讨PHP中OO之静态关键字以及类常量的详解
Jun 07 PHP
PHP fopen()和 file_get_contents()应用与差异介绍
Mar 19 PHP
php中smarty模板条件判断用法实例
Jun 11 PHP
Yii统计不同类型邮箱数量的方法
Oct 18 PHP
php+ajax实现仿百度查询下拉内容功能示例
Oct 20 PHP
Ajax+PHP实现的删除数据功能示例
Feb 12 PHP
PHP针对redis常用操作实例详解
Aug 17 PHP
如何解决PHP获取不到SESSION信息之一般情况
Oct 10 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
ZF等常用php框架中存在的问题
2008/01/10 PHP
Codeigniter实现发送带附件的邮件
2015/03/19 PHP
thinkphp 验证码 的使用小结
2017/05/07 PHP
laravel5.1框架基础之Blade模板继承简单使用方法分析
2019/09/05 PHP
jQuery UI Dialog控件中的表单无法正常提交的解决方法
2010/12/19 Javascript
Chrome Form多次提交表单问题的解决方法
2011/05/09 Javascript
JavaScript判断变量是否为undefined的两种写法区别
2013/12/04 Javascript
JS过滤url参数特殊字符的实现方法
2013/12/24 Javascript
js常用自定义公共函数汇总
2014/01/15 Javascript
解决bootstrap中modal遇到Esc键无法关闭页面
2015/03/09 Javascript
jQuery原型属性和原型方法详解
2015/07/07 Javascript
Bootstrap模态框水平垂直居中与增加拖拽功能
2016/11/09 Javascript
ionic+AngularJs实现获取验证码倒计时按钮
2017/04/22 Javascript
jQuery树插件zTree使用方法详解
2017/05/02 jQuery
JS改变页面颜色源码分享
2018/02/24 Javascript
Vue+axios+WebApi+NPOI导出Excel文件实例方法
2019/06/05 Javascript
jQuery轮播图功能制作方法详解
2019/12/03 jQuery
JS面向对象之多选框实现
2020/01/17 Javascript
解决vue页面渲染但dom没渲染的操作
2020/07/27 Javascript
JavaScript JSON使用原理及注意事项
2020/07/30 Javascript
VUE和Antv G6实现在线拓扑图编辑操作
2020/10/28 Javascript
深入理解javascript中的this
2021/02/08 Javascript
[01:32]寻找你心中的那团火 DOTA2 TI9火焰传递活动今日开启
2019/05/16 DOTA
仅利用30行Python代码来展示X算法
2015/04/01 Python
Fiddler如何抓取手机APP数据包
2016/01/22 Python
python 实现图片上传接口开发 并生成可以访问的图片url
2019/12/18 Python
微信小程序canvas实现水平、垂直居中效果
2020/02/05 HTML / CSS
什么是唯一索引
2015/07/05 面试题
如果重写了对象的equals()方法,需要考虑什么
2014/11/02 面试题
纺织工程专业个人求职信范文
2014/01/27 职场文书
党员自评材料范文
2014/12/17 职场文书
承诺书怎么写 ?
2019/04/16 职场文书
创业计划书之川味火锅店
2019/09/02 职场文书
如何判断微信付款码和支付宝付款码
2021/04/01 PHP
Python入门之基础语法详解
2021/05/11 Python
pytorch--之halfTensor的使用详解
2021/05/24 Python