Home  >  Article  >  Backend Development  >  Compare boolean and integer in php

Compare boolean and integer in php

WBOY
WBOYOriginal
2016-08-04 09:19:541531browse

If the front is 1, is it always true?

Reply content:

If the front is 1, is it always true?

<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


Compare boolean and integer in php

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn