function removeDir($dir) { if (file_exists($dir)) { foreach (new DirectoryIterator($dir) as $file) { if ($file->isDir()) { if (!$file->isDot()) { $this->removeDir($file->getPathname()); } } else { @unlink($file->getPathname()); } } @rmdir($dir); } }