PHP删除文件夹及其文件

<?php
function deletedir($path){
        $openpath = opendir($path);
        while ($f = readdir($openpath)){
            $file = $path.'/'.$f;
            if($f != '.' && $f != '..'){
                if(is_dir($file)){
                    deletedir($file);
                }else{
                    unlink($file);
                }
            }
        }
        closedir($openpath);
        rmdir($path);
    }
?>

  

posted @ 2017-03-10 13:51  Vincefly  阅读(194)  评论(0编辑  收藏  举报