php(tp) 递归删除缓存方法

来源:互联网 发布:mobi 阅读软件 编辑:程序博客网 时间:2024/05/29 13:14

/**
* 清空系统缓存,递归删除文件夹
*/

public function cleanCache(){                                                                  delFile(RUNTIME_PATH);            Cache::clear();             $this->success("操作完成!!!",U('Admin/Admin/index'));            exit();            return $this->fetch();        }function delFile($path,$delDir = FALSE) {    if(!is_dir($path))                return FALSE;           $handle = @opendir($path);    if ($handle) {        while (false !== ( $item = readdir($handle) )) {            if ($item != "." && $item != "..")                is_dir("$path/$item") ? delFile("$path/$item", $delDir) : unlink("$path/$item");        }        closedir($handle);        if ($delDir) return rmdir($path);    }else {        if (file_exists($path)) {            return unlink($path);        } else {            return FALSE;        }    }}