PHP递归删除目录
<?php
function delDir($path){
if(!is_dir($path)){
return null;
}
$hf=opendir($path);
while(($fileName=readdir($hf))!==false){
if($fileName=='.'|| $fileName=='..'){
continue;
}
if(!is_dir($path.'/'.$fileName)){
unlink($path.'/'.$fileName);
}else{
delDir($path.'/'.$fileName);
}
}
closedir($hf);
echo $path.'被删了
';
return rmdir($path);
}
echo delDir('./aa')?'ok':'no';
?>
Dcr163的博客
http://dcr163.cn/77.html(转载时请注明本文出处及文章链接)