Home > Backend Development > PHP Tutorial > PHP deletes a folder and all files under it_PHP tutorial

PHP deletes a folder and all files under it_PHP tutorial

WBOY
Release: 2016-07-13 10:34:19
Original
1219 people have browsed it

   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;

  }

  }

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/752067.htmlTechArticlefunction deldir($dir) { $dh=opendir($dir); while ($file=readdir($dh)) { if($file!=. $file!=..) { $fullpath=$dir./.$file; if(!is_dir($fullpath)) { unlink($fullpath); } else { deldir...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template