==运算符在PHP中是可传递的吗?

问题描述:

在JavaScript中, == 运算符不一定是可传递的:

In JavaScript, the == operator isn't necessarily transitive:

js> '0' == 0
true
js> 0 == ''
true
js> '0' == ''
false

在PHP中是否一样?您能举个例子吗?

Is the same true in PHP? Can you give an example?

== 运算符不能传递。

完全相同的方案在PHP中给出相同的结果。

The exact same scenario gives the same result in PHP.

echo var_dump('0'==0);
echo var_dump(0=='');
echo var_dump('0'=='');

收益率:

boolean true
boolean true
boolean false