Bird
0
0

Given an array of mixed types: [0, '0', false, null, ''], which comparison operator will consider all elements equal to 0 when compared individually?

hard📝 Application Q9 of 15
PHP - Operators
Given an array of mixed types: [0, '0', false, null, ''], which comparison operator will consider all elements equal to 0 when compared individually?
A==
B!==
C===
D!=
Step-by-Step Solution
Solution:
  1. Step 1: Analyze comparison behavior with 0

    Loose equality (==) treats false, null, empty string, and '0' as equal to 0 due to type juggling.
  2. Step 2: Understand strict equality behavior

    Strict equality (===) requires same type and value, so only integer 0 matches 0.
  3. Final Answer:

    Loose equality == considers all elements equal to 0 -> Option A
  4. Quick Check:

    Loose == treats falsy values as equal to 0 [OK]
Quick Trick: == treats falsy values as equal to 0 [OK]
Common Mistakes:
  • Assuming === treats all as equal
  • Ignoring type juggling
  • Confusing != with equality

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes