Pclzip 使用入门



Pclzip 使用入门

  PclZip::PclZip()  : Class creator #实例化类

  PclZip::create()  : Create the PKZIP file and add files or folders #创建压缩文件

  PclZip::listContent()  : List content of an archive #获取压缩文件内容列表

  PclZip::extract()  : Extract all or part of the content of the archive #解压文件/部分文件

  PclZip::properties()  : Get properties of the archive #获取压缩文件信息

  PclZip::add()  : Get properties of the archive #向压缩文件内添加内容(官网写错了)

  PclZip::delete()  : Delete files inside the archive #删除压缩文件内文件

  PclZip::merge()  : Add one archive content in a second archive #合并压缩文件

  PclZip::duplicate()  : Duplicate the archive #复制压缩文件


实例一,创建压缩文件:


include_once('pclzip.lib.php');
$archive = new PclZip('archive.zip');
$v_list $archive->create('file.txt,data/text.txt,folder');
if (
$v_list == 0) {
  die(
"Error : ".$archive->errorInfo(true));
}

实例二,解压文件:

require_once('pclzip.lib.php');
$archive = new PclZip('archive.zip');
if (
$archive->extract() == 0) {
die(
"Error : ".$archive->errorInfo(true));
}


实例三,解压部分文件:

require_once('pclzip.lib.php');
$archive = new PclZip('archive.zip');
if (
$archive->extract(PCLZIP_OPT_BY_NAME, $fiel_list) == 0) {
die(
"Error : ".$archive->errorInfo(true));
}



实例四,获取压缩文件列表:

include_once('pclzip.lib.php');
$zip = new PclZip("test.zip");
if ((
$list $zip->listContent()) == 0) {
  die(
"Error : ".$zip->errorInfo(true));
}
for ($i=0$i<sizeof($list); $i++) {
  for(
reset($list[$i]); $key key($list[$i]); next($list[$i])) {
    echo 
"File $i / [$key] = ".$list[$i][$key]."
";
  }
  echo 
"";

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值