Home  >  Article  >  Backend Development  >  PHP中的一个比较问题

PHP中的一个比较问题

WBOY
WBOYOriginal
2016-06-06 20:32:161148browse

false相当于0
true相当于1
为什么在PHP中 判断true

回复内容:

false相当于0
true相当于1
为什么在PHP中 判断true

不同类型是不能比较的,如果是强比较的话,PHP内部会把2强转成布尔型true,所有2是等于true.

因为PHP是弱类型,比较的时候两个参数要转换成相同类型,所以true 很明显不成立

你需要这个 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