PHP中的copy()函数
copy()函数复制文件。创建了源文件到目标文件的副本。如果目标文件已经存在,它将被覆盖。
语法
copy(source_file, dest_file)
参数
source_file-设置要复制的文件
dest_file-设置要复制到的文件
返回
copy()函数返回。
是的,成功了
失败,失败
示例
<?php
echo copy("D:/myfiles/sourcefile.dat","D:/myfiles/destfile.dat");
?>输出结果
true
现在让我们来看另一个例子。
示例
<?php
$file = '/usr/home/guest/example.txt';
$newfile = '/usr/home/guest/example.txt.bak';
if (!copy($file, $newfile)) {
echo "failed to copy $file...\n";
} else {
echo "copied $file into $newfile\n";
}
?>输出结果
failed to copy /usr/home/guest/example.txt...
热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短