自己写的php移动文件夹函数

类别:编程语言 点击:0 评论:0 推荐:

 function move_d($source,$target){
          if(is_dir($source)){
                  $dest_name=basename($source);
                  if(!mkdir($target.$dest_name)){
                          return false;
                  }
                  $d=dir($source);
                  while(($entry=$d->read())!==false){
                          if(is_dir($source.$entry)){
                                  if($entry=="."||$entry==".."){
                                          continue;
                                  }else{
                                          move_d("$source$entry\\","$target$dest_name\\");
                                  }
                          }else{
                                  if(!copy("$source$entry","$target$dest_name\\$entry")){
                                          return false;
                                  }
                          }
                  }
          }else{
                  if(!copy("$source$entry","$target$dest_name\\")){
                          return false;
                  }
          }
          return true;
  }

本文地址:http://com.8s8s.com/it/it24052.htm