php专区

 首页 > php专区 > PHP应用 > php函数大全 > 如何用php创建与删除多级目录函数 - php函数

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

分享到:
【字体:
导读:
          functiondeldir($dir) { $dh=opendir($dir); while($file=readdir($dh)) { if($file!= $file!= ) { $fullpath=$dir $fil...

如何用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 从字符串中获取URL中获得域名 - php...
php 从字符串中获取URL中获得域名 本教程主要主讲从字符串中得出url的域名部份,下面来看看吧。希望对我有帮助。 例如:http://www.phpfensi.com  得到  www.phpfensi.com function get_domain($url){  $pattern = "/[w-] .(com|net|org|gov|cc|biz|info|cn)(.(cn|hk))*/";  ...
php中文汉字截取函数 - php函数
php中文汉字截取函数 中文汉字截取函数 //要截取的字符串, $num要截取的长度, 返回截取的字符串 public function substrgb($in,$num)       {         //$num=16;         $pos=0;         $bytenum=0;         $out="";   ...
  •         php迷,一个php技术的分享社区,专属您自己的技术摘抄本、收藏夹。
  • 在这里……