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