Operator Precedence in PHP : Tutorial



You must have learn BODMAS rule in alegbra,

ie. Order of operations

Brackets
Orders(ie Powers and roots)
Division
Multiplication
Addition
Subtraction

Operator Precedence specifies how tightly it binds two expressions together.


Example :

2 + 2 * 3 = 8, it is not 12 because multiplication (*) operator has a higher precedence than the addition (+) operator.

(2 + 2) * 3 = 12 , because now Brackets (Parentheses) are given more importance.