加载中…
个人资料
在路上
在路上
  • 博客等级:
  • 博客积分:0
  • 博客访问:362
  • 关注人气:3
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

thinkphp删除Runtime缓存文件夹!

(2013-04-09 11:57:54)
分类: Php

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

 

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

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有