In the PSR-4 instance class implementation
loadClass()
Method in the
How should this line of code be understood?
I think it should be:
while (false !== ($pos = strrpos($prefix, '\\')))
The problem has been resolved:
See ' Notice ' in the PHP operator precedence manual: although = lower precedence than most other operators, PHP still allows expressions similar to the following: if (! $a = foo ()), in this case the return value of foo () is assigned to the $a
How to force PHP to abide by the Convention, this problem do not know if the great God told?
Reply content:
PSR-4 in the methods in the instance class implementation loadClass()
How should this line of code be understood?
I think it should be:
while (false !== ($pos = strrpos($prefix, '\\')))
The problem has been resolved:
See ' Notice ' in the PHP operator precedence manual: although = lower precedence than most other operators, PHP still allows expressions similar to the following: if (! $a = foo ()), in this case the return value of foo () is assigned to the $a
How to force PHP to abide by the Convention, this problem do not know if the great God told?
That's what you understand.
The assignment operator takes precedence over the precedence of the comparison operator, so the assignment is performed first.
The return value of the assignment operator is the right value of the operator.
Update:
The precedence of the assignment operator is lower than the precedence of the comparison operator, but there are special syntax techniques in PHP:
Note:尽管 = 比其它大多数的运算符的优先级低,PHP 仍旧允许类似如下的表达式:if (!$a = foo()),在此例中 foo() 的返回值被赋给了 $a。