This article mainly introduces the function code used to decompress a zip file in php. each function code has a corresponding text comment. For more information, see decompress the zip file function in PHP, the source code is short. you need to use the ZZIPlib library extension. make sure the extension is enabled before use.
<? /********************** @ File-path to zip file the path of the file to be decompressed * @ destination -destination directory for unzipped files, make sure that this extension has enabled */function unzip_file ($ file, $ destination) {// instantiate object $ zip = new ZipArchive (); // open the zip file, if it fails to be opened, a prompt message is returned. if ($ zip-> open ($ file )! = TRUE) {die ("cocould not open archive");} // decompress the compressed file to the specified directory $ zip-> extracation ($ destination ); // close the zip file $ zip-> close (); echo 'archiveextracted to directory';} // test execution // unzip_file ("func.zip ", "jieya");?>
This is the function code for php to decompress the zip file. I hope it will be helpful for your learning.