PHP Bug Hunt Medium +20 XP
Wrong String Comparison
This comparison gives unexpected results.
PHPFind the bug
1
if ($password == 0) {2
// grants access!3
} The bug is on line 1
Select the correct fix
Show answer and explanation
Answer: Use strict comparison === instead of ==
In PHP, '0' == 0 is true due to type coercion. Use === which checks both value AND type, preventing this security bug.
Hint: PHP's == coerces types — use === instead.
What this challenge tests
Bug Hunt in PHP: comparison, security, strict.