Home > Article > Backend Development > How to use zip in PHP_PHP tutorial
How to use zip in PHP
The Zip File feature allows you to read ZIP files.
-------------------------------------------------- -------------------------------
Install
For Zip file functions to work on your server, these libraries must be installed:
The ZZIPlib library Gi Draheim: Download the ZZIPlib library
Zip PELC Extension: Download Zip PELC Extension
Install Linux system
PHP 5+: The zip functions and zip library are not enabled by default and must be downloaded from the link above. Use the -with-zip=direction configuration option to include zip code support.
Installation under Windows system
PHP 5+: The ZIP function is not enabled by default, so the php_zip.dll and ZZIPlib libraries must be linked from above. php_zip.dll must be enabled inside php.ini.
In order to enable any PHP extension, the PHP extension_dir setting (in the php.ini file) should be set to the directory under which the PHP extension library is located. For example extension_dir value is c:php extension.
-------------------------------------------------- -------------------------------
PHP’s Zip file function
PHP: Shows the earliest PHP version with supported features.
Function | Description | PHP |
---|---|---|
zip_close() | Closes a ZIP file | 4 |
zip_entry_close() | Closes an entry in the ZIP file | 4 |
zip_entry_compressedsize() | Returns the compressed size of an entry in the ZIP file | 4 |
zip_entry_compressionmethod() | Returns the compression method of an entry in the ZIP file | 4 |
zip_entry_filesize() | Returns the actual file size of an entry in the ZIP file | 4 |
zip_entry_name() | Returns the name of an entry in the ZIP file | 4 |
zip_entry_open() | Opens an entry in the ZIP file for reading | 4 |
zip_entry_read() | Reads from an open entry in the ZIP file | 4 |
zip_open() | Opens a ZIP file | 4 |
zip_read() | Reads the next entry in a ZIP file | 4 |