INTRODUCTION true == 'x' 'x' == 0 0 == false Thankfully, true != false but coercions in PHP are weird. NUMBER --> BOOLEAN false === (bool) 0 true === (bool) 1 true === (bool) 8 false === (bool) 0.0 true === (bool) 0.1 true === (bool) 0.8 BOOLEAN --> NUMBER 0 === (int) false 1 === (int) true 0.0 === (double) false 1.0 === (double) true STRING --> BOOLEAN false === (bool) '' false === (bool) '0' true === (bool) '0.0' true === (bool) '00' true === (bool) ' 0' true === (bool) 'a' BOOLEAN --> STRING (sigh) '1' === (string) true '' === (string) false ARRAY --> BOOLEAN false === (bool) [] true === (bool) [0] NUMBER --> STRING '0' === (string) 0 '0' === (string) 0.0 '1.2' === (string) 1.2 '-1.2' === (string) -1.2 STRING --> NUMBER 123 === (int) '123' 123 === (int) ' 123abc456' 0 === (int) '' 0 === (int) 'php' -2.8 === (double) '-2.8' 1000.0 === (double) '1e3' 1000 === (int) (double) '1e3' 1 === (int) '1e3' It's probably best just to avoid == and use === ... 1000 == 1000.0 1000.0 == '1e3' 1000 == '1e3' 1 != '1e3' 1 !== 1.0 1 == 1.0 '1' == '1.0' ., +, - 1 . 2 === '12' 'abc3' + 4 === 4 '56' - '7' === 49 1 + '2abc' . 4 === '34' 78 . 9 - '6' === 783