Use zip in PHP

Source: Internet
Author: User
Tags php source code ziparchive

Introduction: This is a detailed page for PHP to use zip. It introduces the knowledge, skills, experience, and some PHP Source Code related to using zip in PHP, PHP, and zip PHP.

Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 350525 'rolling = 'no'>
In PHP, you can use the PHP zip function to pack and decompress some files.

The methods are as follows:

1. Open the extended extension in PHP. ini and enable it (this function will be available in PHP 5.2 and later)

Extension = php_zip.dll

2. compressed files

 
<? // Creating object of the ziparchive $ zip = new ziparchive (); $ ow = 1; $ file = "C: \ master.zip "; if ($ zip-> open ($ file, $ ow? Ziparchive: overwrite: ziparchive: Create) === true) {// Add a file $ zip-> AddFile ("C: \ master.txt "); // a1.txtwill be saved to a2.txt $ zip-> AddFile ("C: \ a1.txt", "C: \ a2.txt"); $ zip-> AddFile ("C: \ a3.txt "); // close $ zip-> close () ;}?>

3. Decompress

 

$ Zip = new ziparchive (); // open master.zip if ($ zip-> open ("master.zip") === true) {// decompressed path $ zip-> extracloud ("/path/to/folder/"); $ zip-> close ();} // extract only one file // open master.zip for extracting single files if ($ zip-> open ("master.zip") === true) {// will extract only fonts.css from master.zip to given path. $ zip-> extracelist ("/path/to/folder/", "fonts.css"); $ zip-> close ();} // decompress multiple files if ($ zip-> open ("master.zip") === true) {$ files = array ("fonts.css", "master.css "); $ zip-> extracloud ("/path/to/folder/", $ files); $ zip-> close ();}

Love J2EE follow Java Michael Jackson video station JSON online tools

Http://biancheng.dnbcw.info/php/350525.html pageno: 3

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.