Home > Article > Backend Development > Compare boolean and integer in php
If the front is 1, is it always true?
Reply content:
<code><?php 1==true //true ,这里的1 会隐式转换成true 非0即真 1===true // false ,这里的是全等于 不会隐式转换,所以为假 </code>
== only determines the value. When the two comparison items are of different types, they will be converted to the type of the previous item for value comparison.
=== The value is also determined by the type. 1 is an integer, true is bool, so it is false