Added the. ZIP file reading function in PHP.

Source: Internet
Author: User
Tags zip extension
PHP adds the. ZIP file reading function This module uses the functions of the ZZIPlib library by Guido Draheim to transparently read ZIP compressed archives and the files inside them.
This module uses the ZZIPlib Library (Guido Draheim) to read ZIP compressed files and files in it.

Please note that ZZIPlib only provides a subset of functions provided in a full implementation of the ZIP compression algorithm and can only read ZIP file archives. A normal ZIP utility is needed to create the ZIP file archives read by this library.
Note: This library is only a subset of all ZIP extension functions and can only read the content in the ZIP document. A common ZIP environment requires creation of ZIP files

Zip support in PHP is not enabled by default. You will need to use the -- with-zip configuration option when compiling PHP to enable zip support. This module requires ZZIPlib version> = 0.10.6.
PHP does not support ZIP by default. you need to use the -- with-zip configuration to compile your PHP. this module requires the ZZPIlib version> = 0.10.6

Note: Zip support before PHP 4.0.7 is experimental. This section reflects the Zip extension as it exists in PHP 4.0.7 and later.
Note: zip is tested before 4.0.7. This chapter is written in php4.0.7 and later versions.

Example Usage
This example opens a ZIP file archive, reads each file in the archive and prints out its contents. The test2.php archive used in this example is one of the test archives in the ZZIPlib source distribution.

Example 1. Zip Usage Example


$ Zip = zip_open ("/tmp/test2.zip ");

If ($ zip ){

While ($ zip_entry = zip_read ($ zip )){
Echo "Name:". zip_entry_name ($ zip_entry). "\ n ";
Echo "Actual Filesize:". zip_entry_filesize ($ zip_entry). "\ n ";
Echo "Compressed Size:". zip_entry_compressedsize ($ zip_entry). "\ n ";
Echo "Compression Method:". zip_entry_compressionmethod ($ zip_entry). "\ n ";

If (zip_entry_open ($ zip, $ zip_entry, "r ")){
Echo "File Contents: \ n ";
$ Buf = zip_entry_read ($ zip_entry, zip_entry_filesize ($ zip_entry ));
Echo "$ buf \ n ";

Zip_entry_close ($ zip_entry );
}
Echo "\ n ";

}

Zip_close ($ zip );

}

?>

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.