PHP uses the Pclzip class to implement file compression method (with Pclzip class download address), _php tutorial

Source: Internet
Author: User
Tags php regular expression

PHP uses the Pclzip class to implement the file compression method (with the Pclzip class download address),


The example in this paper describes how PHP uses the Pclzip class to implement file compression. Share to everyone for your reference, as follows:

Using Pclzip (Zip format) compression, the first need to download its package file ( Click here to download ). The Pclzip feature is pretty powerful, it can compress and decompress, and some methods of adding and removing classes, and so on. Of course, we can find this content on the Internet, not necessarily have to remember. As long as we need to use the time we can quickly find a way to use on the Internet. The first thing we need is to introduce the downloaded library file, as

<?php include (' pclzip/pclzip.lib.php '); >//the address inside the parentheses is changed to the address of their pclzip.lib.php file,//All of its functions are in pclzip.lib.php

We can use it after introduction, and here is a simple way to write when I use it.

<?php$zipname = "Test.zip"; The name of the compressed package $zipnames = '/zipfiles/'. $zipname; The path of the compressed package $z = new Pclzip ($zipnames); Instantiate this pclzip class $v_list = $z->create (' File.txt,data/text.txt,folder '); Compress the file if ($v _list = = 0) {die ("Error:". $archive->errorinfo (true)); If wrong, prompt for error message. }?>

This is a simple zip compression is done, in this method we mainly use the pclzip inside of the Pclzip class and it inside the creation of a compression package method create. From the above example we can see the following content

<?php Pclzip ($zip _filename); >//inside is the name of the package and the path where it resides. It's not about writing the name on it. If the path is not correct, it cannot be found. <?php pclzip::create ($filelist, [optional arguments]);? >//create method to create a compressed package. $filelist can include the name of the file and the folder name, or a string, in the array containing the.//If it is multiple files, it can be separated by commas, as in the above example.

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/1125255.html www.bkjia.com true http://www.bkjia.com/PHPjc/1125255.html techarticle PHP uses the Pclzip class to implement the file compression method (with the Pclzip class download address), this article describes the PHP using the Pclzip class to implement the file compression method. Share to everyone for your reference, specific ...

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