Bird
0
0

Identify the problem in this PHP code:

medium📝 Debug Q7 of 15
PHP - Operators
Identify the problem in this PHP code:
$x = '100';
if ($x === 100) {
echo 'Match';
} else {
echo 'No Match';
}
ASyntax error in if statement
BStrict equality fails due to type mismatch
CVariable $x is undefined
DEcho statement missing semicolon
Step-by-Step Solution
Solution:
  1. Step 1: Check types in strict equality

    $x is string '100', compared strictly to integer 100, so types differ.
  2. Step 2: Understand strict equality behavior

    Strict equality requires both value and type to match, so condition is false and 'No Match' is printed.
  3. Final Answer:

    Strict equality fails due to type mismatch -> Option B
  4. Quick Check:

    Strict === checks type too [OK]
Quick Trick: Strict === fails if types differ even if values match [OK]
Common Mistakes:
  • Assuming '100' === 100 is true
  • Ignoring type differences
  • Thinking code has syntax errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes