Zend
200-550 · Question #146
Which of the following code snippets writes the content of the "source.txt" to "target.txt"?
The correct answer is A. file_put_contents("target.txt", fopen("source.txt", "r")); D. file_put_contents("target.txt", file_get_contents("source.txt")); E. $handle = fopen("target.txt", "w+"); fwrite($handle, file_get_contents("source.txt")); fclose($handle). See the full explanation below for the reasoning.
Question
Which of the following code snippets writes the content of the "source.txt" to "target.txt"?
Options
- Afile_put_contents("target.txt", fopen("source.txt", "r"));
- Bfile_put_contents("target.txt", readfile("source.txt"));
- Cfile_put_contents("target.txt", join(file("source.txt"), ""));
- Dfile_put_contents("target.txt", file_get_contents("source.txt"));
- E$handle = fopen("target.txt", "w+"); fwrite($handle, file_get_contents("source.txt")); fclose($handle);
How the community answered
(15 responses)- A87% (13)
- B7% (1)
- C7% (1)
Community Discussion
No community discussion yet for this question.