Precedence and Associativity

This lesson discusses two important characteristics of arithmetic operators, i.e., precedence and associativity.

Precedence #

Operator precedence determines which operator is performed first in an expression with more than one operators. Operator precedence in PHP is similar to that of regular arithmetic operators.

  • *, /, % operators have equal precedence.
  • + , - operators have equal precedence.
  • *, / , % have a higher precedence than + , -.

The operator with higher precedence is executed first in the expression.

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy