Is the == operator transitive in PHP?

后端 未结 3 969
春和景丽
春和景丽 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:44

    The same is true in PHP:

    //php
    
    '0'==0  //true
    0==''   //true
    ''=='0' //false
    

    Did you not test it yourself? These are the same statements you provided for javascript.

提交回复
热议问题