Php ZipArchive package compressed file usage analysis, _ PHP Tutorial

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.