PHP adds a pair. The reading function of ZIP file _php Foundation

Source: Internet
Author: User
Tags create zip zip extension
This module uses the functions of the Zziplib Library by Guido Draheim to transparently read ZIP compressed archives and T He files inside them.
This module uses the Zziplib library (Guido Draheim) to read the ZIP-compressed document and the files inside it

Please provides a subset of functions provided into a full implementation of the ZIP compression algo Rithm and can only read ZIP file archives. A Normal ZIP utility is needed to create the ZIP file archives read by this library.
Note that this library is only a subset of all of the extension features of zip, and can only read the contents of the zip document. A common zip environment requires the ability to create zip documents

ZIP support in PHP isn't enabled by default. You'll 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 have a default support ZIP, you need to use the--with-zip configuration to compile your PHP. This module requires a 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: The zip is tested before 4.0.7. This chapter is written in php4.0.7 and later versions of Things

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

Example 1. Zip Usage Example

<?php

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