Simple zip compression and decompression

Source: Internet
Author: User
Tags ziparchive

In fact, like this kind of PHP to expand a lot, but the project is not how to use:

<?PHP$zip=Newziparchive ();$filename= "./test112.zip";//to open a compressed package in a pattern created without being presentif($zip->open ($filename, ziparchive::create)!==TRUE){    Exit("Cannot open$filename\ n ");}Else{    //echo "Can be turned on"; Add files like a zipped package and write something in passing    $zip->addfromstring ("test.txt", ' File content goes here! '); Echo $zip-Numfiles; Echo $zip-status; //Add the contents of the test.php file to te.php and add the te.php to the ZIP package    $zip->addfile ("./test.php", "te.php"); $zip->setpassword ("111"); $zip-close ();}//Unzip//$zip = new Ziparchive (),//if ($zip->open ("./test112.zip") = = = TRUE) {//$zip->extractto ("./my/");    Unzip to my directory//$zip->close (); echo "OK";//}

Simple zip compression and decompression

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.