zoukankan      html  css  js  c++  java
  • thinkphp一键清除缓存的方法

    后台控制器:

    <?php
    namespace Home\Controller;
    use Think\Controller;
    class HuancuController extends Controller{
                    private function _deleteDir($R){
                    $handle = opendir($R);
                    while(($item = readdir($handle)) !== false){
                    if($item != '.' and $item != '..'){
                    if(is_dir($R.'/'.$item)){
                    $this->_deleteDir($R.'/'.$item);
                    }else{
                    if(!unlink($R.'/'.$item))
                    die('error!');
                    }
                    }
                    }
                    closedir( $handle );
                    return rmdir($R);
                    }
                    public function clearRuntime(){
                    if($_POST['user']==1){
                            if($this->_deleteDir("./Runtime/")){
                                $this->ajaxReturn(1);
                            }
                    }
                    }
            
    }
    
    前台代码 ajax请求:
    <script type="text/javascript">
        function zp(){
            $.ajax({
                type: "POST",
                url:"{:U('Huancu/clearRuntime')}",
                data:{user:1},
                success:function(r){
                 if(r==1){
                     alert('清除成功!');
                 }
                }
            })
        }
    </script>
    

     https://blog.csdn.net/qq_36892798/article/details/64441754

  • 相关阅读:
    hdu 3033 I love sneakers!
    poj 1742 Coins
    poj 1276 Cash Machine
    hdu 1114 Piggy-Bank
    poj 1293 Duty Free Shop
    hdu 1203 I NEED A OFFER!
    hdu 2546 饭卡
    树的直径
    CF 337D Book of Evil
    ST表
  • 原文地址:https://www.cnblogs.com/lxwphp/p/15454075.html
Copyright © 2011-2022 走看看