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

thinkphp 清理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'));
}

你可能感兴趣的:(thinkphp,php)