<?php function delDir($dir) { // First delete the files in the directory: $ dh = opendir ( $ dir ); while ($file=readdir($dh)) { if($file!="." && $file!="..") { $fullpath=$dir."/".$file; if ($file == '.svn') { delFulldir($fullpath); }else{ if(is_dir($fullpath)) { delDir($fullpath); } } } } closedir($dh); } function delFulldir($dir) { //先删除目录下的文件: $dh = opendir($dir); while ($file = readdir($dh)) { if($file != "." && $file!="..") { $fullpath = $dir."/".$file; if(!is_dir($fullpath)) { unlink($fullpath); } else { delFulldir($fullpath); } } } closedir($dh); // delete the current folder: if ( rmdir ( $dir )) { return true ; } else { return false; } } delDir("C:\wamp\www\dataOld");