Home >Backend Development >PHP Tutorial >PHP zip decompression class pclzip usage example_PHP tutorial
PclZip is a very powerful PHP class for compressing and decompressing zip files. This article mainly introduces how to use PclZip
Introduction to PclZip PclZip is a very powerful PHP class for compressing and decompressing zip files. The PclZip library can compress and decompress Zip format compressed files (WinZip, PKZIP); and can process such files, including generating compressed files and columns. Extract the contents of compressed files and decompress files, etc. Simple, easy to use, and powerful are my evaluations of 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 one: 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)); } ?> Usage two: The code is as follows: < ?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)); } ?>