goodgeneguo Posted November 16, 2006 Share Posted November 16, 2006 Hi I just get started with PHP so this question is probably quite dumb. (but i could not find answers to it by searching google or PHP.net)I saw some code like : $variable1 .= $variable2; What does this mean? What is the difference from $variable1 = $variable2 ?thank you for your attention Link to comment https://forums.phpfreaks.com/topic/27489-php-newbie-has-newbie-question/ Share on other sites More sharing options...
roopurt18 Posted November 16, 2006 Share Posted November 16, 2006 It's string concatenation.$var = 'Hello';$var .= ', World!';echo $var;Outputs:Hello, World! Link to comment https://forums.phpfreaks.com/topic/27489-php-newbie-has-newbie-question/#findComment-125663 Share on other sites More sharing options...
Psycho Posted November 16, 2006 Share Posted November 16, 2006 That is the same thing as:$variable1 = $variable1 . $variable 2;So if $variable1 = "Tom" and $variable2 = "Jones" and you run$variable1 .= $varialbe2Then $variable1 will now equal "TomJones" Link to comment https://forums.phpfreaks.com/topic/27489-php-newbie-has-newbie-question/#findComment-125664 Share on other sites More sharing options...
roopurt18 Posted November 16, 2006 Share Posted November 16, 2006 I guess I should have been more specific. I may be mistaken, but I believe all operators of the form:$var1 [i]op[/i]= $var2;are equivalent to:$var1 = $var1 [i]op[/i] $var2;I.E:$var1 = $var1 + $var2 is equivalent to $var1 += $var2$var1 = $var1 . $var2 is equivalent to $var1 .= $var2 Link to comment https://forums.phpfreaks.com/topic/27489-php-newbie-has-newbie-question/#findComment-125683 Share on other sites More sharing options...
Orio Posted November 16, 2006 Share Posted November 16, 2006 You are right.Orio. Link to comment https://forums.phpfreaks.com/topic/27489-php-newbie-has-newbie-question/#findComment-125694 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.