Say I\'ve got a file test.php in foo directory as well as bar. How can I replace bar/test.php with foo/test.php
test.php
foo
bar
bar/test.php
foo/test.php
You could use the rename() function :
rename('foo/test.php', 'bar/test.php');
This however will move the file not copy