PHP头条
热点:

删除文件夹下的所有文件及子文件-PHP源码


php代码

function deldir($dir) {
  //先删除目录下的文件:
  $dh=opendir($dir);
  while ($file=readdir($dh)) {
    if($file!="." && $file!="..") {
      $fullpath=$dir."/".$file;
      if(!is_dir($fullpath)) {
          unlink($fullpath);
      } else {
          deldir($fullpath);
      }
    }
  }
  closedir($dh);
  //删除当前文件夹:
  if(rmdir($dir)) {
    return true;
  } else {
    return false;
  }
}

deldir('../aaa');

www.phpzy.comtrue/phpyy/41627.htmlTechArticle删除文件夹下的所有文件及子文件-PHP源码 php代码 function deldir($dir) { //先删除目录下的文件: $dh=opendir($dir); while ($file=readdir($dh)) { if($file!="." $file!="..") { $fullpath=$dir."/".$file; if(!is_dir($fu...

相关文章

PHP之友评论

今天推荐