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
<? 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 );
}
?>