的PHP优先,我读了=
比and
运营商
更高的优先级比方说,你有
$boolone = true;
$booltwo= false;
$res = $boolone and $booltwo;
我已经猜到这会变成假的,因为$res = true and false
其中真假等于假。但由于=
具有更高的优先级,它应该是真实的。这是这样的
($res = $boolone) and $booltwo;
这将返回true,但我的问题是为什么它返回true,它不应该返回false?由于$res = $boolone
等于true
和$booltwo
默认为false,所以我们有这样的:true and false
这通常应该返回false,但是为什么又是true?
简单地说:
($res = $boolone) and $booltwo;
(true) and false; //returns true?
如果这是为了实际的实际目的,请尝试'$ res = $ boolone && $ booltwo;' – mega6382
@ mega6382我只是想了解它背后的理论。不实用(还) – KoyaCho