Bird
0
0

Which of the following is the correct syntax to open a file for appending in PHP?

easy📝 Syntax Q3 of 15
PHP - File Handling
Which of the following is the correct syntax to open a file for appending in PHP?
Afopen($file, "w")
Bfopen($file, "r")
Cfopen($file, "a")
Dfopen($file, "x")
Step-by-Step Solution
Solution:
  1. Step 1: Recall append mode syntax

    "a" is the mode to open a file for appending data at the end.
  2. Step 2: Verify other modes

    "r" is read, "w" is write (truncate), "x" is create new file only.
  3. Final Answer:

    Use fopen with "a" to append -> Option C
  4. Quick Check:

    Append mode = "a" [OK]
Quick Trick: Use "a" to add data at file end without erasing [OK]
Common Mistakes:
  • Using "w" to append (it overwrites)
  • Using "r" which is read-only
  • Confusing "x" with append mode

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes