nerdexam
National_Instruments

200-500 · Question #186

Which of the following code snippets writes the content of the file "source.txt" to "target.txt"? (Choose 3)

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")). See the full explanation below for the reasoning.

Question

Which of the following code snippets writes the content of the file "source.txt" to "target.txt"? (Choose 3)

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"));

How the community answered

(40 responses)
  • A
    83% (33)
  • B
    13% (5)
  • C
    5% (2)

Community Discussion

No community discussion yet for this question.

Full 200-500 Practice