假设我在 foo
目录以及 bar
中有一个文件 test.php
。如何使用 PHP
将 bar/test.php
替换为 foo/test.php
?我使用的是 Windows XP,跨平台解决方案会很棒,但首选 Windows。
最佳答案
您可以使用 copy()
功能:
// Will copy foo/test.php to bar/test.php
// overwritting it if necessary
copy('foo/test.php', 'bar/test.php');
引用其手册页中的几个相关句子:
Makes a copy of the file source to dest.
If the destination file already exists, it will be overwritten.
关于php - 如何使用 PHP 将文件从一个目录复制到另一个目录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5772769/