function deldir($dir) { // $dir是相对路径
$dh=opendir($dir);
while ($file=readdir($dh)) { // readdir函数返回目录中下一个文件的文件名。文件名以在文件系统中的排序返回
if($file!="." && $file!="..") {
$fullpath=$dir."/".$file;
if(!is_dir($fullpath)) { // is_dir函数:如果文件名存在并且为目录则返回 TRUE
unlink($fullpath); // unlink函数删除文件
} else {
deldir($fullpath);
}
}
}
closedir($dh);
if(rmdir($dir)) { // rmdir函数删除目录
return true;
} else {
return false;
}
}