PHP Operators Altering operator precedence (with parentheses)

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

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.



Got any PHP Question?