【问题标题】:Operator precedence and associativity only determine how expressions are grouped, they do not specify an order of evaluation运算符优先级和关联性仅确定表达式的分组方式,它们不指定求值顺序
【发布时间】:2013-10-21 16:52:22
【问题描述】:

来自 PHP 文档:

运算符优先级和关联性仅决定表达式的方式 被分组,它们没有指定评估顺序。

表示这段代码可能会报错?:

$a = true || new bla(); // bla class doesn't exist

【问题讨论】:

    标签: php operator-precedence


    【解决方案1】:

    没有。

    评估顺序是正常的从左到右。不是优先级/关联性。

    只是分组如下:

    (true) || (new bla())
    

    该语句没有被执行,因为第一个语句为真(短路);这由逻辑或运算符指定(在运行时)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-12-03
      • 2017-10-25
      • 2021-10-04
      • 1970-01-01
      • 2020-06-23
      • 2021-05-05
      • 2013-12-28
      • 2019-12-21
      相关资源
      最近更新 更多