Home  >  Article  >  Backend Development  >  php delete directory and all files_PHP tutorial

php delete directory and all files_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:58:27824browse

function del($name) {
  if (!is_dir($name)) {
   return @unlink($name);
  } else {
   $dir = opendir($name);
   while( $file = readdir( $dir ) ) {
    if (($file=='.')||($file=='..')) continue;
    if (is_dir($name.'/'.$file)) $this->del($name.'/'.$file);
    else echo basename($file), @unlink($name.'/'.$file) ? ' Success!' : ' False.', '
';
   }
  closedir($dir);
  }
  return @rmdir($name);
 }

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/632003.htmlTechArticlefunction del($name) { if (!is_dir($name)) { return @unlink($name); } else { $dir = opendir($name); while( $file = readdir( $dir ) ) { if (($file=='.')||($file=='..')) continue; if...
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