在php中,有时会遇到=操作符的优先级问题。
比如:
PHP在线中文手册中的说明:
Although = has a lower precedence than most other operators, PHP will still allow expressions similar to the following: if (!$a = foo()), in which case the return value of foo() is put into $a.
因此,输出结果为1。
希望以上的小例子,有助于大家理解php中=操作符的优先级,及其用法。