Home >php教程 >php手册 >php删除文件夹及其文件夹下所有文件

php删除文件夹及其文件夹下所有文件

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-13 09:39:26943browse

   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;

  }

  }

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn