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:
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
|
< ?phpinclude_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'); |
if ($v_list == 0) {
die("Error : ".$archive->errorInfo(true));
}
?> ; Usage 2: The code is as follows
|
Copy code |
< ?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...
|