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

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

  

原文地址:https://www.cnblogs.com/huangye-dream/p/3396179.html