清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
我们可以使用RecursiveDirectoryIterator 和 RecursiveIteratorIterator删除目录和子目录及文件,子目录将先与父目录删除
<?php function cleanup_directory($dir) { $iter = new RecursiveDirectoryIterator($dir); foreach (new RecursiveIteratorIterator($iter, RecursiveIteratorIterator::CHILD_FIRST) as $f) { if ($f->isDir()) { rmdir($f->getPathname()); } else { unlink($f->getPathname()); } } rmdir($dir); } cleanup_directory('c:\\wamp\\junk'); ?>