Are there any specific PHP functions or methods that can be used for file replacement, beyond copy and unlink?

When replacing a file in PHP, the common approach is to use the `copy` function to duplicate the new file and then `unlink` to remove the old file. However, another method to replace a file is to use the `rename` function, which can atomically move a file from one location to another, effectively replacing it.

// Example of using the rename function to replace a file
$oldFile = 'path/to/old/file.txt';
$newFile = 'path/to/new/file.txt';

// Replace the old file with the new file
if (rename($newFile, $oldFile)) {
    echo 'File replaced successfully.';
} else {
    echo 'Failed to replace file.';
}