Bird
0
0

Which of the following is a correct way to write a single-line comment in PHP?

easy📝 Conceptual Q11 of 15
PHP - Basics and Execution Model
Which of the following is a correct way to write a single-line comment in PHP?
A<!-- This is a single-line comment -->
B// This is a single-line comment
C/* This is a single-line comment */
D# This is not a comment
Step-by-Step Solution
Solution:
  1. Step 1: Identify single-line comment syntax in PHP

    PHP supports single-line comments using // and #.
  2. Step 2: Check each option

    // This is a single-line comment uses // correctly. is HTML comment syntax, not PHP. /* This is a single-line comment */ is multi-line comment syntax. # This is a single-line comment is also valid in PHP, so # This is not a comment is correct as well.
  3. Final Answer:

    // This is a single-line comment -> Option B
  4. Quick Check:

    Single-line comment = // or # [OK]
Quick Trick: Single-line comments start with // or # in PHP [OK]
Common Mistakes:
  • Confusing HTML comments with PHP comments
  • Using multi-line comment syntax for single-line comments
  • Thinking # is not a valid comment

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes