How do I understand this line of code in a PSR-4 instance?

Source: Internet
Author: User
Tags php operator
How should I understand the {code...} line of code in the loadClass () method in the implementation of the PSR-4 instance class? I think it should be: {code ...} the problem has been solved: see 'notice 'in the PHP operator priority Manual: although the priority is lower than that of most other operators, PHP still... implementation of PSR-4 instance class loadClass()Method

while (false !== $pos = strrpos($prefix, '\\')) 

How should this line of code be understood?

I think it should be:

while (false !== ($pos = strrpos($prefix, '\\')))

The problem has been solved:
See 'notice 'in the PHP operator priority manual ':Although = has a lower priority than most other operators, PHP still allows expressions similar to the following: if (! $ A = foo (). In this example, the return value of foo () is assigned to $.

How to force PHP to comply with the Conventions?

Reply content:

Implementation of PSR-4 instance classloadClass()Method

while (false !== $pos = strrpos($prefix, '\\')) 

How should this line of code be understood?

I think it should be:

while (false !== ($pos = strrpos($prefix, '\\')))

The problem has been solved:
See 'notice 'in the PHP operator priority manual ':Although = has a lower priority than most other operators, PHP still allows expressions similar to the following: if (! $ A = foo (). In this example, the return value of foo () is assigned to $.

How to force PHP to comply with the Conventions?

That's what you understand.

The priority of the value assignment operator is higher than that of the comparison operator. Therefore, the value assignment operation is performed first.

The Return Value of the value assignment operator is the right value of the operator.

Update:

The priority of the value assignment operator is lower than that of the comparison operator, but PHP has special syntax skills:

Note: Although = has a lower priority than most other operators, PHP still allows expressions similar to the following: if (! $ A = foo (). In this example, the return value of foo () is assigned to $.

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.