/*递归删除目录及目录下的文件*/ function del_dir($dir){ $files = new DirectoryIterator($dir); foreach ($files as $fileInfo) { if($fileInfo->isDot()){ continue; } $filename = $fileInfo->getPathname(); if($fileInfo->isDir()){ del_dir($filename); }else{ unlink($filename); } } if(rmdir($dir)) { return true; } else { return false; } }