Php Tutorial operator priority:
Calculate multiplication, division, and addition and subtraction. When brackets are encountered, calculate the values in brackets.
The operator priority specifies how closely two expressions are bound ". For example, the result of expression 1 + 5*3 is 16 instead of 18 because the priority of the multiplication sign ("*") is higher than that of the plus sign ("+. If necessary, use parentheses to forcibly change the priority. Example: (1 + 5) the value of * 3 is 18. If the operator priority is the same, the left join order from left to right is used.
Operator priority combined with additional operator information
Not combined with clone new clone and new
Left [array ()
Non-union ++ -- increment/decrease operator
Not Associated ~ -(Int) (float) (string) (array) (object) (bool) @ Type
Uncombined instanceof type
Right join! Logical operators
Left */% arithmetic operator
Left +-. Arithmetic operators and string operators
Left <> bitwise operator
Non-union <<=>=<> comparison operator
Not combined =! ===! = Comparison operator
Left & bit operators and references
Left ^ bit operator
Left | bitwise operator
Left & logical operators
Left | logical operator
Left? : Ternary operator
Right = + =-= * =/=. = % = & =|=^= <<=>> = value assignment operator
Left and logical operators
Left xor logical operator
Left or logical operators
Left, used in multiple places
Example name result
-$ A: returns the negative value of $.
$ A + $ B addition: sum of $ a and $ B.
The difference between $ a-$ B subtraction $ a and $ B.
The product of $ a * $ B multiplication $ a and $ B.
$ A/$ B Division $ a divided by the operator of $ B.
$ A % $ B modulo $ a divided by the remainder of $ B.
<? Php
$ A = 10;
$ B = 20;
Echo-$ a; // returns the negative value of $. -10
Echo "<br/> ";
Echo $ a + $ B; // add the sum of $ a and $ B. 30
Echo "<br/> ";
Echo $ a-$ B; // subtraction between $ a and $ B. -10
Echo "<br/> ";
Echo $ a * $ B; // multiply the product of $ a and $ B. 200
Echo "<br/> ";
Echo $ a/$ B; // Division $ a divided by the operator of $ B. 0.5
Echo "<br/> ";
Echo $ a % $ B; // modulus $ a divided by the remainder of $ B. 10
Echo "<br/> ";
?>
<? Php
$ A = 3*3% 5; // (3*3) % 5 = 4
$ A = true? 0: true? 1: 2; // (true? 0: true )? 1: 2 = 2
$ A = 1;
$ B = 2;
$ A = $ B + = 3; // $ a = ($ B + = 3)-> $ a = 5, $ B = 5
?>