Php ZipArchive method for packaging compressed files ,. The ZipArchive method for packaging compressed files in php is described in this article. For your reference, the details are as follows: the usage analysis of ZipArchive method for packaging compressed files in php,
This document describes how to use ZipArchive to package and compress php files. We will share this with you for your reference. The details are as follows:
As mentioned above, the PclZip method for packaging compressed files in php is another simpler method today. it uses ZipArchive to compress files. This is an extension class of php. it has been supported since php5.2. if you encounter an error while using it, check php. in ini, have you removed the semicolon before extension = php_zip.dll, and then restart Apache to use this class library.
It is very simple to use ZipArchive to compress files. The php official website has provided me with many examples. you can refer to http://www.php.net/manual/zh/class.ziparchive.php, for example:
<? Php $ zip = new ZipArchive; // first instantiate this class if ($ zip-> open('test.zip ') = TRUE) {// after all, the compressed package test.zip exists. $ zip-> addFile ('Too. php '); $ zip-> addFile ('test. php '); // upload the too.php and test.php files to the $ zip-> close (); // close echo' OK ';} else {echo 'failed';}?>
The following are some parameter descriptions:
<? Php/******** ziparchive optional parameter ******** // * 1. zipArchive: addEmptyDir add a new file directory 2. zipArchive: addFile: add the file to the specified zip package. 3. zipArchive: addFromString: add the content to the file at the same time. 4. zipArchive: close ziparchive5.ZipArchive: extracloud unzip the compressed package 6. zipArchive: open a zip package. zipArchive: getStatusString returns the status content during compression, including error information and compression information. zipArchive: deleteIndex delete a file in the compressed package, for example, deleteIndex (0) delete the first file 9. zipArchive: deleteName: delete a file name in the compressed package, and delete the file ....... */?>
In short, it is more convenient to use ZipArchive for file compression as long as you have php5.2 or later versions. Which of the following operations is faster than PclZip? This Lei Zi has not been tested yet. if you are interested, you can try again and again.