thinkphp删除Runtime缓存文件夹

    xiaoxiao2021-03-25  90

    多话不说,直接附上代码:如下       

     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>';     } 

     

    /下面是处理方法

          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

    转载请注明原文地址: https://ju.6miu.com/read-39049.html

    最新回复(0)