This article mainly introduces the PHP decompression zip file function. Interested friends can refer to it. I hope it will be helpful to everyone.
The code is as follows:
<? /********************** *@file - path to zip file 需要解压的文件的路径 *@destination - destination directory for unzipped files 解压之后存放的路径 *@需要使用 ZZIPlib library ,请确认该扩展已经开启 */ function unzip_file($file, $destination){ // 实例化对象 $zip = new ZipArchive() ; //打开zip文档,如果打开失败返回提示信息 if ($zip->open($file) !== TRUE) { die ("Could not open archive"); } //将压缩文件解压到指定的目录下 $zip->extractTo($destination); //关闭zip文档 $zip->close(); echo 'Archive extracted to directory'; } //测试执行 //unzip_file("func.zip","jieya"); ?>
Summary: The above is the entire content of this article, I hope it will be helpful to everyone's study.
Related recommendations:
Detailed explanation of Trait features and role examples in PHP
Detailed explanation and cases of PHP namespaces and automatic loading classes
Summary on the automatic loading method in php
The above is the detailed content of PHP decompression zip file function. For more information, please follow other related articles on the PHP Chinese website!