Altering operator precedence with parentheses

suggest change

The order in which operators are evaluated is determined by the operator precedence (see also the Remarks section).

In

$a = 2 * 3 + 4;

$a gets a value of 10 because 2 * 3 is evaluated first (multiplication has a higher precedence than addition) yielding a sub-result of 6 + 4, which equals to 10.

The precedence can be altered using parentheses: in

$a = 2 * (3 + 4);

$a gets a value of 14 because (3 + 4) is evaluated first.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents