Home  >  Article  >  Backend Development  >  基础:关于PHP松散比较

基础:关于PHP松散比较

WBOY
WBOYOriginal
2016-06-23 14:02:011053browse

比如:
"php"  == true   
请问松散比较两边类型不一致时,是以左右那边类型为准进行转换, 并比较?

是否是 "php"转换为0  ==  true转换为"true"再转换为0 ? 
不懂的是,转换是以左右那边类型为准进行转换并比较
请老鸟指点,谢谢。


回复讨论(解决方案)

看这里
http://www.php.net/manual/zh/language.operators.comparison.php

看这里
http://www.php.net/manual/zh/language.operators.comparison.php

高手,我看了1个小时没看懂才来问的啊,能指点下吗

bool 或 null  任何其它类型  转换为 bool,FALSE 

bool 或 null  任何其它类型  转换为 bool,FALSE 
唉 又是复制手册上的话 ,我等菜鸟要是手册看的懂就不来问了

"php"  == true   

任何其他类型与bool 类型比较,其他类型会转换为 bool 类型,这里php会转化true。所以结果为真。

"php"  == true   

任何其他类型与bool 类型比较,其他类型会转换为 bool 类型,这里php会转化true。所以结果为真。

非常感谢,我会努力看懂手册,谢谢

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