Home > Backend Development > PHP Tutorial > PclZip plug-in file decompression and compression in php_PHP tutorial

PclZip plug-in file decompression and compression in php_PHP tutorial

WBOY
Release: 2016-07-20 11:10:38
Original
1143 people have browsed it

Recently I was developing my WordPress plug-in ShareLink. In the process, I discovered PclZip, a PHP class for operating zip files, and I have to recommend it. Another reason for recommendation is that I discovered a lewd usage of PHP function parameters in its source code. An example will be given below.

Generate zip file
Usage 1:

if ($v_list == 0) {
The code is as follows
 代码如下 复制代码

< ?php

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));

}

?>

Copy code


< ?php

include_once('pclzip.lib.php');
 代码如下 复制代码

< ?php

include_once('pclzip.lib.php');

$archive = new PclZip('archive.zip');

$v_list = $archive->create('data/file.txt,data/text.txt',

PCLZIP_OPT_REMOVE_PATH, 'data',

PCLZIP_OPT_ADD_PATH, 'install');

if ($v_list == 0) {

die("Error : ".$archive->errorInfo(true));

}

?>

$archive = new PclZip('archive.zip');

$v_list = $archive->create('file.txt,data/text.txt,folder');

die("Error : ".$archive->errorInfo(true));

}

Usage 2:
The code is as follows Copy code
< ?php
include_once('pclzip. lib.php');
<🎜>$archive = new PclZip('archive.zip');<🎜><🎜>$v_list = $archive->create('data/file.txt,data/ text.txt',PCLZIP_OPT_REMOVE_PATH, 'data',PCLZIP_OPT_ADD_PATH, 'install');if ($v_list == 0) {die("Error : ".$archive->errorInfo(true));}?> If you see that there are no parameters in the create method, then you will know what to do if you look at the method prototype. At least I haven’t used it this way http://www.bkjia.com/PHPjc/444715.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/444715.htmlTechArticleRecently I was developing my WordPress plug-in ShareLink. In the process, I discovered PclZip, a PHP class that operates zip files. , I have to recommend it. There is another reason why it is recommended...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template