Which of the following code snippets write content from one file to another file?
Each correct answer represents a complete solution. Choose all that apply.
[1384,1386,1387]
Correct:
--> $handle = fopen("target.txt","w+"); fwrite($handle,file_get_contents("source.txt")); fclose($handle);
--> $src = fopen('source.txt', 'r'); $dest = fopen('target.txt', 'w'); stream_copy_to_stream($src,$dest);
--> file_put_contents("target.txt",file_get_contents("source.txt"));
Explanation:
Answer options D, A, and C are correct.
You can write contents from one file to another file by using the following PHP code snippets:
file_put_contents("target.txt",file_get_contents("source.txt"));
$handle = fopen("target.txt","w+"); fwrite($handle,file_get_contents("source.txt")); fclose($handle);
$src = fopen('source.txt', 'r'); $dest = fopen('target.txt', 'w'); stream_copy_to_stream($src,$dest);
Answer option B is incorrect. This is not a valid syntax of the stream_copy_to_stream()
function.
Reference: PHP