计算机网络/计算机科学与应用/系统/运维/开发

Tp6 清除缓存

Common.php 

// 删除目录及文件,传入目录
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);
}


Config.php  控制器下

// 清空runtime下缓存文件
public function del_cache()
{
    // 删除runtime 目录
    $path = root_pth().'runtime';
    delFileByDir($path);
    return alert('清除缓存成功','index/index',6);
}

日子过着过着就有了答案,努力走着走着就有了温柔的着落。

评论

^