PHP Packaging Compressed file Ziparchive method usage analysis, _php tutorial

Source: Internet
Author: User
Tags close close php regular expression php website ziparchive

PHP Packaging Compressed file Ziparchive method usage analysis,


This article describes the Ziparchive method usage of PHP packaging compressed files. Share to everyone for your reference, as follows:

In front of the PHP packaging compressed file Pclzip method, today, another easier way to use ziparchive to compress the file. This is the PHP extension class, since the php5.2 version has been supported this extension, if you are using the error, check the php.ini inside the EXTENSION=PHP_ Zip.dll in front of the semicolon has not been removed, and then restart Apache to use this class library.

The use of ziparchive compressed files is very simple, the PHP website has provided me with a lot of relevant examples, you can see the 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) {//and then see if there is a test.zip this compressed package  $zip->addfile (' too.php ');  $zip->addfile (' test.php '); Add too.php and test.php two files to the Test.zip compressed package  $zip->close ();//Close  echo ' OK ';} else {  echo ' failed ';}? >

Here are some parameter descriptions:

<?php/******** ziparchive Optional parameter *******//*1.ziparchive::addemptydir add a new file directory 2.ziparchive::addfile Adds a file to the specified zip archive. 3.ziparchive::addfromstring adds the content to the file at the same time 4. Ziparchive::close close Ziparchive5. Ziparchive::extractto Unzip the package 6. Ziparchive::open Open a ZIP archive package 7. Ziparchive::getstatusstring returns the state content at the time of compression, including error messages, compression information, and so on 8. Ziparchive::d eleteindex Delete One of the files in the compressed package, such as: Deleteindex (0) Delete the first file 9. Ziparchive::d eletename Delete One of the file names in the compressed package, and also delete the files. ......*/?>

In short, as long as your php5.2 version above, the use of ziparchive to file compression is more convenient. Specific and pclzip which run faster, this Lei son has not done a test, we are interested can toss toss.

More about PHP related content readers can view this site topic: "PHP operation zip file and compression skills summary", "PHP file Operation Summary", "PHP Regular Expression Usage summary", "PHP operation and operator Usage Summary", "PHP Basic Grammar Introductory Tutorial", " PHP Primer for object-oriented programming, PHP string Usage Summary, Introduction to PHP+MYSQL database operations, and PHP common database operations Tips Summary

I hope this article is helpful to you in PHP programming.

http://www.bkjia.com/PHPjc/1125254.html www.bkjia.com true http://www.bkjia.com/PHPjc/1125254.html techarticle PHP Packaging Compressed file Ziparchive method Usage analysis, this article describes the PHP packaging compressed file Ziparchive method usage. Share to everyone for your reference, as follows: Said before ...

  • 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.