.is_file:判断是否是文件

is_dir:判断是否为目录

file_exists  = is_file + is_dir   判断是文件或目录 

function delDir($dirPath) {

  $dir = opendir($dirPath);

  while ($file = readdir($dir)) {

    if ($file == '.' || $file == '..') {

      continue ; 

    }

    $filePath = $dirPath.'/'.$file;

    if (is_file($filePath)) {

      unlink($filePath);

    } else {

      delDir($dirPath);

    }

  }

  rmdir($dirPath);

  closedir($dir);

}

相关文章:

  • 2021-10-05
  • 2021-09-26
  • 2021-11-30
  • 2022-01-27
  • 2021-06-17
  • 2021-07-31
  • 2022-02-06
  • 2021-12-15
猜你喜欢
  • 2022-12-23
  • 2021-10-09
  • 2022-03-01
  • 2022-12-23
  • 2022-02-26
  • 2021-04-20
  • 2021-05-26
相关资源
相似解决方案