Home>Article>Backend Development> Detailed explanation of PHP operator precedence
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!
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.
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)》
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!