TypechoJoeTheme

Dcr163的博客

统计

PHP递归删除目录

2016-03-13
/
0 评论
/
798 阅读
/
正在检测是否收录...
03/13

<?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.'被删了<br/>';
return rmdir($path);
 
}
 
echo delDir('./aa')?'ok':'no';
 
 
?>
朗读
赞(0)
版权属于:

Dcr163的博客

本文链接:

https://www.dcr163.cn/75.html(转载时请注明本文出处及文章链接)

评论 (0)

人生倒计时

今日已经过去小时
这周已经过去
本月已经过去
今年已经过去个月

最新回复

  1. https://Sites.google.com/view/vavada-online-casino
    2025-04-12
  2. https://x.com/jeetbuzzcom
    2025-04-07
  3. prozone.cc alternative
    2025-03-19
  4. urgent delivery
    2025-03-16
  5. faster indexing
    2025-03-05

标签云