The condition uses = which assigns '5' to $x instead of comparing.
Step 2: Understand effect of assignment in condition
Assignment returns the assigned value, which is truthy, so 'Equal' always prints regardless of original $x.
Final Answer:
Assignment (=) used instead of comparison (==) -> Option C
Quick Check:
Use == for comparison, not = [OK]
Hint: Use == for comparison, not = assignment [OK]
Common Mistakes:
Confusing = with == in conditions
Thinking strict comparison is error here
Ignoring that assignment returns value
5. You want to filter an array to keep only elements that are exactly integer 0, excluding string '0'. Which comparison operator should you use in PHP?
hard
A. ==
B. !==
C. !=
D. ===
Solution
Step 1: Understand filtering requirement
We want to keep only elements that are integer 0, not string '0'. So type matters.
Step 2: Choose operator that checks type and value
Strict equality (===) checks both value and type, so it excludes string '0'.
Final Answer:
=== -> Option D
Quick Check:
Strict equality === filters exact type and value [OK]
Hint: Use === to match exact type and value [OK]
Common Mistakes:
Using == which allows type conversion
Using != or !== which exclude 0
Ignoring type difference in filtering
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.