|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-11-28 18:49 UTC] john@php.net
[2003-06-21 13:27 UTC] moriyoshi@php.net
[2004-07-26 16:51 UTC] vrana@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Nov 04 19:00:02 2025 UTC |
The operators page at /manual/en/language.operators.php lists the the assignment operators (=, +=, etc.) as being left associative, but they must logically be right associative. Left associativity would mean that this: $a = $b = 0; was interpreted as: ($a = $b) =0; which is clearly nonsensical. Indeed a quick test shows that: $d = $c += $a += $b += 4; is interpreted as: $d = ($c += ($a += ($b += 4))); which looks like right associativity to me! (Actually, a little further testing suggests that the assignment operators need some special annotations, as they don't appear to strictly obey their stated precedence level. For example, the statement: $x = $z + $y = 543; if interpreted strictly according to the precedence rules should be equivalent to: $x = ($z + $y) = 543; which would be a parse error, but in fact is interpreted as: $x = $z + ($y = 543); which may be the "obvious" intention, but had me WTF-ing for a while!!)