php递归删除目录及子文件文件夹
$path='./phpMyAdmin'; function delAll($path){ if(is_dir($path)){ $handle=opendir($path); //$file=readdir($handle); 为什么不能在外面读取目录句柄 while(false !== ($file = readdir($handle))){ if($file=='.' ||$file=='..'){ continue; } if(is_dir($path.'/'.$file)){ delAll($path.'/'.$file); }else{ unlink($path.'/'.$file); //删除文件 } } closedir($handle); //关闭目录句柄 rmdir($path); //删除空目录 }else{ echo "不是目录"; } } delAll($path);
希望广大博友给予建议和指导