Edit report at https://bugs.php.net/bug.php?id=65551&edit=1
ID: 65551 Updated by: ras...@php.net Reported by: nukboon at gmail dot com Summary: Compare 0 variable alway return true -Status: Open +Status: Not a bug Type: Bug Package: Unknown/Other Function Operating System: Centos 6 PHP Version: 5.5.3 Block user comment: N Private report: N New Comment: You are mixing types, so type-juggling comes into effect. (int)'id' is 0 and thus 0==0. Read http://php.net/juggling Previous Comments: ------------------------------------------------------------------------ [2013-08-25 16:39:20] nukboon at gmail dot com Description: ------------ See below my testing script. I've test with all version of php it's return same result. Test script: --------------- $a = 0; if($a == 'id'){ echo 'Yes' . PHP_EOL; } var_dump($a); var_dump($a == 'id'); var_dump($a == 'ids'); var_dump($a == 'def'); $a = 1; if($a == 'id'){ echo 'Yes' . PHP_EOL; } var_dump($a); var_dump($a == 'id'); var_dump($a == 'ids'); var_dump($a == 'def'); // Result Yes int(0) bool(true) bool(true) bool(true) int(1) bool(false) bool(false) bool(false) Expected result: ---------------- $a = 0; var_dump($a == 'abc'); //should be: bool(false) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=65551&edit=1