Home >php教程 >PHP源码 >删除文件目录 代码

删除文件目录 代码

PHP中文网
PHP中文网Original
2016-05-25 17:12:071734browse

跳至

  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
Previous article:php最小马Next article:webqq机器人实现