Bird
0
0

What value does the null coalescing operator ?? return if the left side is null?

easy📝 Conceptual Q1 of 15
PHP - Conditional Statements
What value does the null coalescing operator ?? return if the left side is null?
ANull
BAn error
CThe value on the right side
DFalse
Step-by-Step Solution
Solution:
  1. Step 1: Understand the null coalescing operator

    The operator ?? returns the left operand if it is not null; otherwise, it returns the right operand.
  2. Step 2: Apply to the given scenario

    If the left side is null, the operator returns the right side value.
  3. Final Answer:

    The value on the right side -> Option C
  4. Quick Check:

    Null coalescing returns right value if left is null [OK]
Quick Trick: If left is null, ?? returns right value [OK]
Common Mistakes:
  • Thinking it returns null
  • Expecting an error
  • Confusing with OR operator

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes