谁能解释一下这里发生了什么?
if(2 && 5 < 4)
如果我有例如
$x = 2 && 3;
和var_dump($x),无论数字是什么,它都会给出boolean(true)。但是这里看起来数字是一个接一个和4比较的
查看PHP的比较表http://php.net/manual/en/types.comparisons.php
对于整数,非0的数在比较中返回true。
if (2 && 5 < 4) => if (true && false) => false
$x = 2 && 3 = 1 && 1 = 1
,因为如果变量为整数值,则由于类型转换,true变为1。