Forum Moderators: coopster

Message Too Old, No Replies

appending stings shortcut?

         

Sarah Atkinson

4:21 pm on Oct 27, 2005 (gmt 0)

10+ Year Member



is
$foo = $foo . 'bar';
the same thing as

$foo .='bar';
?

chrisjoha

4:53 pm on Oct 27, 2005 (gmt 0)

10+ Year Member



yes :) just the same way as

$i = $i + 1;
is the same as
$i += 1; (and $i++; or ++$i;)

and so on

coopster

5:08 pm on Oct 27, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



True, except that Sarah is using strings as opposed to numbers. The actual term here is called the concatenating assignment operator ('.=') [php.net], which appends the argument on the right side to the argument on the left side.

Sarah Atkinson

5:42 pm on Oct 27, 2005 (gmt 0)

10+ Year Member



nifty time saving trick. I like it. noticed it in some code I got off the internet and though wow that's either a typo or kinda cool. looks very clean