How does this line of code in the PSR-4 instance understand?

Source: Internet
Author: User
Tags php operator
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。
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.