thinkphp3.2刪除Runtime快取資料夾
阿新 • • 發佈:2019-02-10
public function del_cache() {
header("Content-type: text/html; charset=utf-8");
//清檔案快取
$dirs = array('./Runtime/');
@mkdir('Runtime',0777,true);
//清理快取
foreach($dirs as $value) {
$this->rmdirr($value);
}
$this->assign("jumpUrl","__ROOT__/");
$this->success('系統快取清除成功!');
//echo '<div style="color:red;">系統快取清除成功!</div>';
}
header("Content-type: text/html; charset=utf-8");
//清檔案快取
$dirs = array('./Runtime/');
@mkdir('Runtime',0777,true);
//清理快取
foreach($dirs as $value) {
$this->rmdirr($value);
}
$this->assign("jumpUrl","__ROOT__/");
$this->success('系統快取清除成功!');
//echo '<div style="color:red;">系統快取清除成功!</div>';
}
/////////////下面是處理方法
public function rmdirr($dirname) {
if (!file_exists($dirname)) {
return false;
}
if (is_file($dirname) || is_link($dirname)) {
return unlink($dirname);
}
$dir = dir($dirname);
if($dir){
while (false !== $entry = $dir->read()) {
if ($entry == '.' || $entry == '..') {
continue;
}
//遞迴
$this->rmdirr($dirname . DIRECTORY_SEPARATOR . $entry);
}
}
$dir->close();
return rmdir($dirname);
}
文章來源:http://blog.sina.com.cn/s/blog_827ddd9501019ggl.html