note 78345 added to language.operators.assignment
| From: | HayleyWatson at osu1 dot php dot net | Date: | Sun, 07 Oct 2007 22:22:17 +0000 |
| Subject: | note 78345 added to language.operators.assignment | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-131213@lists.php.net to get a copy of this message | ||
bradlis7 at bradlis7 dot com's description is a bit confusing. Here it is rephrased.
<?php
$a = 'a';
$b = 'b';
$a .= $b .= "foo";
echo $a,"\n",$b;?>
outputs
abfoo
bfoo
Because the assignment operators are right-associative and evaluate to the result of the assignment
<?php
$a .= $b .= "foo";
?>
is equivalent to
<?php
$a .= ($b .= "foo");
?>
and therefore
<?php
$b .= "foo";
$a .= $b;
?>
----
Server IP: 203.89.181.186
Probable Submitter: 60.234.168.92
----
Manual Page -- http://www.php.net/manual/en/language.operators.assignment.php
Edit -- https://master.php.net/note/edit/78345
Del: integrated -- https://master.php.net/note/delete/78345/integrated
Del: useless -- https://master.php.net/note/delete/78345/useless
Del: bad code -- https://master.php.net/note/delete/78345/bad+code
Del: spam -- https://master.php.net/note/delete/78345/spam
Del: non-english -- https://master.php.net/note/delete/78345/non-english
Del: in docs -- https://master.php.net/note/delete/78345/in+docs
Del: other reasons-- https://master.php.net/note/delete/78345
Reject -- https://master.php.net/note/reject/78345
Search -- https://master.php.net/manage/user-notes.php