当前位置: 首页 > 图文教程 > 网络编程 > PHP > php在线打包/解包

PHP
《PHP设计模式介绍》第十三章 适配器模式
《PHP设计模式介绍》第十四章 动态记录模式
《PHP设计模式介绍》第十五章 表数据网关模式
《PHP设计模式介绍》第十六章 数据映射模式
《PHP设计模式介绍》第十七章 MVC 模式
Zend Framework 入门——快速上手
Zend Framework 入门——多国语言支持
Zend Framework 入门——错误处理
Zend Framework 入门——页面布局
详细介绍php5编程中的异常处理
PHP5 OOP编程中的代理与异常
PHP程序的常见漏洞攻击分析
PHP.MVC的模板标签系统
PHP教程:PHP编码书写规范
PHP开发大型项目的方法:OOP思想
php使用curl模拟用户登陆
php对gb编码动态转utf-8编码的几种方法评测
php设计模式介绍之章代理模式
“在phpMyAdmin使用用户口令登陆”补充
PHP入门速成

PHP 中的 php在线打包/解包


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-19   浏览: 714 ::
收藏到网摘: n/a

  1. /** 
  2. * @ 在线打包函数 createZip($zipfile, $dir) 
  3. * @ 在线解包函数 extractZip($zipfile, $dir) 
  4. * @ $zipfile 压缩包名称 
  5. * @ $dir 打包/解包目录 
  6. * @ by 李奕权 
  7. */  
  8. function createZip($zipfile$dir){  
  9.   $zip = new ZipArchive;  
  10.   if($zip->open($zipfile, ZipArchive::CREATE)){  
  11.     $files = listdir($dir);  
  12.     foreach($files as $path) {  
  13.       if($zip->addFile($path,str_replace("./","",str_replace("\\","/",$path))) == flase) exit('Failture, stoped from '.$path);  
  14.     }  
  15.     $zip->close();  
  16.   }  
  17. }  
  18.   
  19. function extractZip($zipfile$dir){  
  20.   $zip = new ZipArchive;  
  21.   if ($zip->open($zipfile) === true) {  
  22.       $zip->extractTo($dir);  
  23.       $zip->close();  
  24.   } else {  
  25.       echo 'Failture!';  
  26.   }