• Welcome to Journal web site.

我是 PHP 程序员

- 开发无止境 -

Next
Prev

PHP复制文件夹及文件夹内的文件_啊啊啊K的博客_php 复制文件夹

Data: 2018-09-23 02:19:18Form: JournalClick: 10

PHP复制文件夹及文件夹内的文件
这个方法正常用没事,遇到 文件夹名为 0 时就会报错

  1.  
    /**
         * copy 文件夹
         * @param $source 源文件目录
         * @param $destination 复制目录
         * @param int $child 类型 1包括子目录 0不包括子目录
         * @return int
         */
        public function xCopy($source, $destination, $child = 1)
        {
            if(!is_dir($source)){
                return 0;
            }
            if(!is_dir($destination)){
                mkdir($destination,0777);
            }
            $handle= dir($source);
            while($entry = $handle->read()) {
                if(($entry!=".")&&($entry!="..")){
                    if(is_dir($source."/".$entry)){
                        if($child){
                            $this -> xCopy($source."/".$entry,$destination."/".$entry,$child);
                        }
                    }else{
                        copy($source."/".$entry,$destination."/".$entry);
                    }
                }
            }
            return 1;
        }
Name:
<提交>