$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);
php递归删除目录及子文件文件夹
原文地址:http://www.cnblogs.com/mengor/p/7774957.html