- <?php function delete_directory($dir) {
- if ($dh = @opendir($dir)) {
- while (($file = readdir ($dh)) != false) {
- if (($file == ".") || ($file == "..")) continue;
- if (is_dir($dir . '/' . $file))
- delete_directory($dir . '/' . $file);
- else
- unlink($dir . '/' . $file);
- }
- @closedir($dh);
- rmdir($dir);
- }
- }
- $dir = "./fakeDir";
- delete_directory($dir);
- ?>
来源: http://www.phpxs.com/code/1003179/