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与XML、XSLT、Mysql的结合运用实现代码
Nov 19 PHP
PHP在引号前面添加反斜杠(PHP去除反斜杠)
Sep 28 PHP
php打开远程文件的方法和风险及解决方法
Nov 12 PHP
THINKPHP项目开发中的日志记录实例分析
Dec 01 PHP
ioncube_loader_win_5.2.dll的错误解决方法
Jan 04 PHP
PHP简单的MVC框架实现方法
Dec 01 PHP
PHP 使用 Imagick 裁切/生成缩略图/添加水印自动检测和处理 GIF
Feb 19 PHP
Yii2实现log输出到file及database的方法
Nov 12 PHP
PHP基于DateTime类解决Unix时间戳与日期互转问题【针对1970年前及2038年后时间戳】
Jun 13 PHP
PHP封装的验证码工具类定义与用法示例
Aug 22 PHP
关于Yii中模型场景的一些简单介绍
Sep 22 PHP
php5.3/5.4/5.5/5.6/7常见新增特性汇总整理
Feb 27 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+redis消息队列实现抢购功能
2018/02/08 PHP
Laravel定时任务的每秒执行代码
2019/10/22 PHP
Jquery下的26个实用小技巧(jQuery tips, tricks &amp; solutions)
2010/03/01 Javascript
javascript替换已有元素replaceChild()使用介绍
2014/04/03 Javascript
JavaScript中检查对象property的存在性方法介绍
2014/12/30 Javascript
基于jQuey实现鼠标滑过变色(整行变色)
2015/12/07 Javascript
分享我对JS插件开发的一些感想和心得
2016/02/04 Javascript
简单了解Backbone.js的Model模型以及View视图的源码
2016/02/14 Javascript
JavaScript自动点击链接 防止绕过浏览器访问的方法
2017/01/19 Javascript
vue下跨域设置的相关介绍
2017/08/26 Javascript
判断滚动条滑到底部触发事件(实例讲解)
2017/11/15 Javascript
babel之配置文件.babelrc入门详解
2018/02/22 Javascript
vue页面切换到滚动页面显示顶部的实例
2018/03/13 Javascript
vue.js中npm安装教程图解
2018/04/10 Javascript
利用JS实现一个同Excel表现的智能填充算法
2018/08/13 Javascript
详解javascript对数组和json数组的操作
2019/04/15 Javascript
Vue在H5 项目中使用融云进行实时个人单聊通讯
2020/12/14 Vue.js
tensorflow更改变量的值实例
2018/07/30 Python
Python实现查询某个目录下修改时间最新的文件示例
2018/08/29 Python
python制作图片缩略图
2019/04/30 Python
解决yum对python依赖版本问题
2019/07/05 Python
简单了解django索引的相关知识
2019/07/17 Python
python3实现在二叉树中找出和为某一值的所有路径(推荐)
2019/12/26 Python
Python检测端口IP字符串是否合法
2020/06/05 Python
行政管理人员精品工作推荐信
2013/11/04 职场文书
《木笛》教学反思
2014/03/01 职场文书
小学生期末评语大全
2014/04/21 职场文书
财务管理专业求职信
2014/06/11 职场文书
英语自我介绍演讲稿
2014/09/01 职场文书
小学竞选班长演讲稿
2014/09/09 职场文书
离职感谢信怎么写
2015/01/22 职场文书
就业推荐表院系意见
2015/06/05 职场文书
2015年度考核个人工作总结
2015/10/24 职场文书
初一数学教学反思
2016/02/17 职场文书
彻底弄懂Python中的回调函数(callback)
2022/06/25 Python
Python可视化神器pyecharts之绘制地理图表练习
2022/07/07 Python