read())) { if ($item == '.' || $item == '..') { continue; } if (is_dir($op->path . '/' . $item)) { self::file_delete_all($op->path . '/' . $item); rmdir($op->path . '/' . $item); } else { unlink($op->path . '/' . $item); } } if ($delall == 1) { rmdir($path); } } //查找目录下所有php文件 static function file_findphp($path) { $up_filestree = self::file_tree($path); $upgrade = array(); foreach ($up_filestree as $sf) { $file_bs = substr($sf, -3); if ($file_bs == 'php') { $upgrade[] = array('path' => str_replace($path . '/', "", $sf), 'fullpath' => $sf); } } return $upgrade; } //删除所有空目录 static function file_rm_empty_dir($path) { if (is_dir($path) && ($handle = opendir($path)) !== false) { while (($file = readdir($handle)) !== false) {// 遍历文件夹 if ($file != '.' && $file != '..') { $curfile = $path . '/' . $file; // 当前目录 if (is_dir($curfile)) {// 目录 self::file_rm_empty_dir($curfile); // 如果是目录则继续遍历 if (count(scandir($curfile)) == 2) {//目录为空,=2是因为.和..存在 rmdir($curfile); // 删除空目录 } } } } closedir($handle); } } }