Bird
0
0

Why does PHP require explicit file closing after operations instead of automatic closing?

hard📝 Conceptual Q10 of 15
PHP - File Handling
Why does PHP require explicit file closing after operations instead of automatic closing?
ABecause files are always closed automatically
BBecause PHP cannot detect when script ends
CTo prevent any file from being opened
DTo give programmers control over resource management
Step-by-Step Solution
Solution:
  1. Step 1: Understand resource management in PHP

    Explicit closing lets programmers decide when to free resources.
  2. Step 2: Recognize PHP's design choice

    Automatic closing happens at script end, but explicit close is better for control.
  3. Final Answer:

    To give programmers control over resource management -> Option D
  4. Quick Check:

    Explicit close = programmer control [OK]
Quick Trick: Close files explicitly to manage resources well [OK]
Common Mistakes:
  • Assuming PHP always closes files automatically immediately
  • Thinking files cannot be closed manually
  • Believing PHP cannot detect script end

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes