您的位置:首页 > 编程语言 > PHP开发

[转]PHP复制整个文件夹的FUNCTION

2011-03-02 17:30 197 查看
/**
* 复制文件夹
* @param str $source		源文件夹
* @param str $destination 	目标文件夹
* @param bool $child 		true则带有子目录的复制
*/
function xCopy($source, $destination, $child = true) {
if (! is_dir ( $source )) {
echo ("Error:the   $source   is   not   a   direction!");
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)
xCopy ( $source . "/" . $entry, $destination . "/" . $entry, $child );
} else {
copy ( $source . "/" . $entry, $destination . "/" . $entry );
}

}
}

return true;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: