PHP adds read functionality to the. zip file _php

Source: Internet
Author: User
Keywords Read function file add Zip the zip_entry
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 archive and the files inside it

Please note this zziplib only provides a subset of functions provided in 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: This library is just a subset of all the extensions in zip, and can only read the contents of the zip document. A normal zip environment requires the ability to create zip documents

ZIP support for PHP is not enabled by default. You'll need to use the--with-zip if the configuration option is compiling PHP to enable zip support. This module requires Zziplib version >= 0.10.6.
PHP does not have default support for ZIP, you need to use--with-zip configuration to compile your PHP. This module requires 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 prior to 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, reads each file in the archive and prints out of 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


$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);

}

?>
  • Related Article

    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.