加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

如何用php创建与删除多级目录函数

发布时间:2020-12-13 20:50:33 所属栏目:PHP教程 来源:网络整理
导读:function deldir( $dir ) { $dh =opendir( $dir ); while ( $file =readdir( $dh )) { if ( $file != . $file != .. ) { $fullpath = $dir . / . $file ; if (! is_dir ( $fullpath )) { unlink( $fullpath ); } else { $this -deldir( $fullpath ); } } } c
  1.  
  2. function deldir($dir)  
  3. {  
  4.    $dh=opendir($dir);  
  5.    while ($file=readdir($dh))  
  6.    {  
  7.   if($file!="." && $file!="..")  
  8.   {  
  9. $fullpath=$dir."/".$file;  
  10. if(!is_dir($fullpath))  
  11. {  
  12. unlink($fullpath);  
  13. }  
  14. else 
  15. {  
  16. $this -> deldir($fullpath);  
  17. }  
  18.   }  
  19.    }  
  20.    closedir($dh);  
  21.    if(rmdir($dir))  
  22.    {  
  23. return true;  
  24.    }  
  25.    else 
  26.    {  
  27. return false;  
  28.    }  
  29. }  
  30.  
  31. function createFolder($path)  
  32. {  
  33.    if (!file_exists($path)){  
  34.    createFolder(dirname($path));  
  35.    mkdir($path, 0777);  
  36. }  

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读