如何判断函数是否已经执行过一次?
ps:有没有其他复制函数扩展,复制过程中忽略没改动的文件,改动的即覆盖掉<?php
//复制函数扩展 xcopy: dir2dir, file2file, file2dir, for windows... by zyme
function xcopy($source, $dest){
if ( !file_exists($source) ){return "error: $source is not exist!";}
if ( is_dir($source) ){
if ( file_exists($dest) AND !is_dir($dest) ){return "error: $dest is not a dir!";}
if ( !file_exists($dest) ){mkdir($dest);}
$od = opendir($source);
while ( $one = readdir($od) ){
if ( $one=="." OR $one==".." ){continue;}
$result = xcopy($source."\\".$one, $dest."\\".$one, $oncemore=true);
if ( $result !== true ){return $result;}
}
closedir($od);
}
else{
if ( file_exists($dest) AND is_dir($dest) ){
if ( func_num_args()>2 AND $oncemore===true ){return "error: $dest is a dir!";}
$result = xcopy($source, $dest."\\".basename($source), $oncemore=true);
if ( $result !== true ){return $result;}
}
else{copy($source, $dest); touch($dest, filemtime($source));}
}
return true;
}
/*以下是问题重点,上面的是别人copy函数扩展,可整目录拷贝。
*/
$dir1="./source/";
$dir1="./direction/";
if(){ //请问如何判断之前是否已经复制过?如果复制过一次,则不再复制
xcopy($dir1,$dir2)
}
?>
ps:有没有其他复制函数扩展,复制过程中忽略没改动的文件,改动的即覆盖掉<?php
//复制函数扩展 xcopy: dir2dir, file2file, file2dir, for windows... by zyme
function xcopy($source, $dest){
if ( !file_exists($source) ){return "error: $source is not exist!";}
if ( is_dir($source) ){
if ( file_exists($dest) AND !is_dir($dest) ){return "error: $dest is not a dir!";}
if ( !file_exists($dest) ){mkdir($dest);}
$od = opendir($source);
while ( $one = readdir($od) ){
if ( $one=="." OR $one==".." ){continue;}
$result = xcopy($source."\\".$one, $dest."\\".$one, $oncemore=true);
if ( $result !== true ){return $result;}
}
closedir($od);
}
else{
if ( file_exists($dest) AND is_dir($dest) ){
if ( func_num_args()>2 AND $oncemore===true ){return "error: $dest is a dir!";}
$result = xcopy($source, $dest."\\".basename($source), $oncemore=true);
if ( $result !== true ){return $result;}
}
else{copy($source, $dest); touch($dest, filemtime($source));}
}
return true;
}
/*以下是问题重点,上面的是别人copy函数扩展,可整目录拷贝。
*/
$dir1="./source/";
$dir1="./direction/";
if(){ //请问如何判断之前是否已经复制过?如果复制过一次,则不再复制
xcopy($dir1,$dir2)
}
?>
解决方案 »
- php中$_SERVER[PHP_SELF] 和 $_SERVER[SCRIPT_NAME]之间的区别
- php中如何取得动态获取的IP地址的最后一段数字
- 字符串问题
- 关于传递的参数写入数据库
- php的copy函数在linux下需要多大的权限?
- 怎么传递头部,帮帮小妹,第2次问这个问题了
- 在线等!!!PHP+mysql上传图片
- 如何动态获取PHP中的时间
- 与市场上通过网站的web发送短信相反,web能接受短信吗?如何完成?
- $table = '`'.DB_pre.$table.'`';这儿为什么要用到反引号啊?
- 关于PHP下载程序如何支持迅雷
- 为什么我mysql_fetch_array只收到一个元素?
static $flg=0;
if($flg===0){
xcopy($dir,$dir2);
$flg++;
}
if ( !file_exists($dest) ){mkdir($dest);} 判断目标文件是否存在,不存在则复制
if ( file_exists($dest) AND is_dir($dest) ){
}
else{copy($source, $dest); touch($dest, filemtime($source));}