Bird
0
0

What will be the output of this PHP code?

medium📝 Predict Output Q5 of 15
PHP - Type Handling
What will be the output of this PHP code?
$a = 0;
$b = '0';
if ($a === $b) { echo 'Equal'; } else { echo 'Not Equal'; }
ANot Equal
BEqual
CError
DNo output
Step-by-Step Solution
Solution:
  1. Step 1: Understand strict comparison with 0 and '0'

    Strict comparison checks type and value; integer 0 and string '0' differ in type.
  2. Step 2: Evaluate if condition

    Since types differ, condition is false, so echo 'Not Equal' executes.
  3. Final Answer:

    Not Equal -> Option A
  4. Quick Check:

    0 === '0' is false [OK]
Quick Trick: === checks type, so 0 !== '0' [OK]
Common Mistakes:
  • Assuming === ignores type
  • Expecting 'Equal' output
  • Confusing == and ===

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes