首页 > Web开发 > 详细

php递归删除目录及子文件文件夹

时间:2017-11-02 22:57:18      阅读:243      评论:0      收藏:0      [点我收藏+]
$path=‘./phpMyAdmin‘;

function delAll($path){
    if(is_dir($path)){
        $handle=opendir($path);
        //$file=readdir($handle);        为什么不能在外面读取目录句柄        
        while(false !== ($file = readdir($handle))){
            if($file==‘.‘ ||$file==‘..‘){
                continue;
            }
            if(is_dir($path.‘/‘.$file)){
                delAll($path.‘/‘.$file);
            }else{
                unlink($path.‘/‘.$file);    //删除文件
            }
        }
        closedir($handle);      //关闭目录句柄
        //rmdir($path);           //删除空目录
    }else{
        echo "不是目录";
    }
}


delAll($path);

 

php递归删除目录及子文件文件夹

原文:http://www.cnblogs.com/mengor/p/7774957.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!