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...