Home>Article>Backend Development> Detailed explanation of PHP operator precedence

Detailed explanation of PHP operator precedence

醉折花枝作酒筹
醉折花枝作酒筹 Original
2021-04-01 17:40:18 5343browse

In php, an operation may have multiple operators connected together. We determine the order of execution of the operation. Below, the editor will introduce the php operator priority to everyone. I hope it will be helpful to friends who need it. help!

Detailed explanation of PHP operator precedence

The rule followed in PHP operations is: operators with high priority are executed first, and operators with low priority are executed later. In the case of the same priority, execution is from left to right. Of course, you can also use parentheses like mathematical operations, and the operators in the parentheses are executed first.

The following table lists the operators in PHP in order of priority from high to low. Operators in the same line have the same precedence, and their combination direction determines the direction of the order of operations.

Detailed explanation of PHP operator precedence

His result is:

false true

The running result is:

14 7 4 4

It can be seen from the above three examples that for For operators in the same column, left represents operations from left to right, and right represents operations from right to left. If the combination direction is not applicable, it means that they cannot be used together.

Related recommendations:

2021 PHP interview questions summary (collection)

php video tutorial

The above is the detailed content of Detailed explanation of PHP operator precedence. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn