thinkphp 清理runtime缓存的方法, 清理指定目录

时间:2022-06-04 08:13:59

https://blog.csdn.net/qq_22823581/article/details/79081497

hinkphp 清理runtime缓存的方法, 清理指定目录

function delFileByDir($dir) {
   $dh = opendir($dir);
   while ($file = readdir($dh)) {
      if ($file != "." && $file != "..") {

         $fullpath = $dir . "/" . $file;
         if (is_dir($fullpath)) {
            delFileByDir($fullpath);
         } else {
            unlink($fullpath);
         }
      }
   }
   closedir($dh);
}
public function del() {
   delFileByDir(APP_PATH.'Runtime/');
   $this->success('删除缓存成功!',U('Admin/Index/index'));
}