删除指定文件路径下的所有文件及文件夹

<?php 
  function deletefolder($path) 
  { 
    if ($handle=opendir($path)) 
    { 
      while (false!==($file=readdir($handle))) 
      { 
        if ($file<>"." AND $file<>"..") 
        { 
          if (is_file($path.'/'.$file)) 
          { 
            @unlink($path.'/'.$file); 
          } 
          if (is_dir($path.'/'.$file)) 
          { 
            deletefolder($path.'/'.$file); 
            @rmdir($path.'/'.$file); 
          } 
        } 
      } 
    } 
  } 
?>

  

posted @ 2013-10-30 10:41  joy696163  阅读(466)  评论(0编辑  收藏  举报