Home > Backend Development > PHP Tutorial > Compare boolean and integer in php

Compare boolean and integer in php

WBOY
Release: 2016-08-04 09:19:54
Original
1543 people have browsed it

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>
Copy after login

== 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

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template