PHP 8.5.0 Alpha 2 available for testing

Voting

: max(eight, eight)?
(Example: nine)

The Note You're Voting On

asc at putc dot de
10 years ago
PHP uses a temporary variable for combined assign-operators (unlike JavaScript), therefore the left-hand-side (target) gets evaluated last.

Input:
$a += $b + $c;

Meaning:
$a = ($b + $c) + $a;

Not:
$a = $a + ($b + $c);

This can be important if the target gets modified inside the expression.

$a = 0;
$a += (++$a) + (++$a); // yields 5 (instead of 4)

<< Back to user notes page

To Top