Php 和运算符行为(带/不带括号)
为什么案例“a”为真Php 和运算符行为(带/不带括号),php,Php,为什么案例“a”为真 我认为and&&具有相同的优先级,但是 如文件所述,这是预期的bahvior $a = true and false; //true $b = true && false; //false $c = (true and false); //false $d = (true && false); //false 常量true被分配给$a,然后忽略false。这都是关于运算符优先级的赋值运算符=的优先级高于和。检查。 // The consta
我认为and&&具有相同的优先级,但是 如文件所述,这是预期的bahvior
$a = true and false; //true
$b = true && false; //false
$c = (true and false); //false
$d = (true && false); //false
常量true被分配给$a,然后忽略false。这都是关于运算符优先级的赋值运算符
=
的优先级高于和
。检查。
// The constant true is assigned to $h and then false is ignored
// Acts like: (($h = true) and false)
$h = true and false;