PHP 清除缓存文件

    /*清除缓存文件*/
    public function clearRuntime()
    {
        $this->delFileByDir(RUNTIME_PATH);
        $this->success('删除缓存成功!');
    }

    /**
     * 递归删除缓存文件
     * @param $dir
     */
    public function delFileByDir($dir) {
        $dh = opendir($dir);
        while ($file = readdir($dh)) {
            if ($file != "." && $file != "..") {
                $fullpath = $dir . "/" . $file;
                if (is_dir($fullpath)) {
                    $this->delFileByDir($fullpath);
                } else {
                    unlink($fullpath);
                }
            }
        }
        closedir($dh);
    }

猜你喜欢

转载自blog.csdn.net/qq_37995146/article/details/80335794