Bird
0
0

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

easy📝 Conceptual Q1 of 15
PHP - Operators
What value does the null coalescing operator ?? return if the left operand is null?
AThe left operand's value
BNull
CAn error
DThe right operand's value
Step-by-Step Solution
Solution:
  1. Step 1: Understand the null coalescing operator behavior

    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 operand is null, the operator returns the right operand's value.
  3. Final Answer:

    The right operand's value -> Option D
  4. Quick Check:

    Null coalescing operator returns right operand if left is null = A [OK]
Quick Trick: Returns right value if left is null, else left [OK]
Common Mistakes:
  • Thinking it returns null if left is null
  • Expecting an error when left is null
  • Confusing with ternary operator

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes