时间: 2020-10-12|tag:29次围观|0 条评论

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

  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. }  

本站声明:网站内容来源于网络,如有侵权,请联系我们,我们将及时处理。

本博客所有文章如无特别注明均为原创。
复制或转载请以超链接形式注明转自起风了,原文地址《如何用php创建与删除多级目录函数 – php函数
   

还没有人抢沙发呢~