Bird
0
0

Why does PHP allow both // and # for single-line comments?

hard📝 Conceptual Q10 of 15
PHP - Basics and Execution Model
Why does PHP allow both // and # for single-line comments?
ATo support different programming styles and compatibility
BBecause # is used only in HTML comments
CBecause // is deprecated
DTo confuse beginners
Step-by-Step Solution
Solution:
  1. Step 1: Understand PHP comment history

    PHP supports multiple comment styles for flexibility and compatibility with other languages.
  2. Step 2: Purpose of multiple styles

    // is common in C-like languages; # is common in shell scripting.
  3. Final Answer:

    Supports different styles and compatibility -> Option A
  4. Quick Check:

    Multiple comment styles reason = B [OK]
Quick Trick: PHP supports // and # for style compatibility [OK]
Common Mistakes:
  • Thinking # is HTML comment
  • Believing // is deprecated
  • Assuming confusion is intentional

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes