Is the == operator transitive in PHP?

后端 未结 3 971
春和景丽
春和景丽 2021-01-17 22:13

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

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

3条回答
  •  一个人的身影
    2021-01-17 22:57

    No, the == operator is not transitive.

    The exact same scenario gives the same result in PHP.

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

    yields:

    boolean true
    boolean true
    boolean false 
    

提交回复
热议问题