PHP函数封装之文件解压

  • A+
所属分类:PHP

有压缩,就一定有解压。

压缩函数:https://www.lijinlong.cc/php/2567.html

 

压缩代码

  1. //解压文件(解压的文件,解压的目录路径)
  2. function unzip_file(string $zipName,string $dest){
  3. //判断解压包是否存在
  4.     if (!is_file($zipName)){
  5.         return false;
  6.     }
  7.     //判断目录是否存在,没有则创建
  8.     if (!is_dir($dest)){
  9.         mkdir($dest,0777,true);
  10.     }
  11.     $zip = new  ZipArchive();
  12.     if ($zip ->open($zipName)){
  13.         $zip->extractTo($dest);
  14.         $zip ->close();
  15.         return true;
  16.     }else{
  17.         return false;
  18.     }
  19. }
  20. unzip_file('4.php.zip','/file/file_function/');
李金龙

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: