/** * 删除文件夹 * * @param string $aimDir * @return boolean */ function unlinkDir($aimDir) { $aimDir = str_replace('', '/', $aimDir); $aimDir = substr($aimDir, -1) == '/' ? $aimDir : $aimDir . '/'; if (!is_dir($aimDir)) { return false; } $dirHandle = opendir($aimDir); while (false !== ($file = readdir($dirHandle))) { if ($file == '.' || $file == '..') { continue; } if (!is_dir($aimDir . $file)) { UtilFile::unlinkFile($aimDir . $file); } else { UtilFile::unlinkDir($aimDir . $file); } } closedir($dirHandle); return rmdir($aimDir); }