当前位置: 首页 > 图文教程 > 网络编程 > PHP > 模拟xcopy的函数

PHP
编写自己的php扩展函数
用Socket发送电子邮件
Get或Post提交值的非法数据处理
一个可查询所有表的“通用”查询分页类
拼音码表的生成
一个odbc连mssql分页的类
用PHP动态创建Flash动画
如何使用PHP获取网络上文件
PHP中路径问题的解决方案
论坛头像随机变换代码
十天学会php(2)
十天学会php(1)
十天学会php(3)
PHP自动生成月历代码
关于PHP中的Class的几点个人看法
Win9x/ME下Apache+PHP安装配置
基于PHP+MySQL的聊天室设计
PHPlet在Windows下的安装
Search Engine Friendly的URL设计
如何给phpadmin一个保护

PHP 中的 模拟xcopy的函数


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 50 ::
收藏到网摘: n/a


模拟xcopy的函数 <?php
/*************************************
* 系统名称:模拟xcopy的函数
* 程序功能:模拟xcopy的函数
* 开发日期:2003/03/14
*************************************/
?>
<?
//copy a direction's all files to another direction
function xCopy($source, $destination, $child){
//用法:
// xCopy("feiy","feiy2",1):拷贝feiy下的文件到 feiy2,包括子目录
// xCopy("feiy","feiy2",0):拷贝feiy下的文件到 feiy2,不包括子目录
//参数说明:
// $source:源目录名
// $destination:目的目录名
// $child:复制时,是不是包含的子目录
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 1;
}
?>