【发布时间】:2018-07-25 13:41:38
【问题描述】:
从我所见,运算符优先级在这两个示例中是有意义的:
$a = false;
$b = true;
$c = $a || $b;
这里 $c 是 true
$a = false;
$b = true;
$c = $a or $b;
这里 $c 是 false
我理解它背后的原因。但是如下:
$a = false;
$b = true;
return $a or $b;
返回真,这让我很困惑。
这是什么原因?
【问题讨论】:
-
这在the manual for PHP operators中有记录。
-
@Qirel 它在哪里提到运算符优先级不适用于返回语句?
-
运算符优先级仅适用于运算符。
return不是操作员。如果该页面明确列出了运算符优先级不适用的所有内容,那么它将有几百页长。
标签: php operator-precedence comparison-operators