What are the advantages and disadvantages of using the copy() function in PHP for transferring files between servers?

Using the copy() function in PHP to transfer files between servers can be advantageous as it is a simple and straightforward method. However, it may not be the most efficient option for transferring large files or when dealing with unreliable network connections.

$file_to_copy = 'http://example.com/file_to_copy.txt';
$destination_path = '/path/to/destination/file.txt';

if (copy($file_to_copy, $destination_path)) {
    echo "File copied successfully!";
} else {
    echo "Failed to copy file.";
}