chard Posted September 13, 2007 Share Posted September 13, 2007 Here's the format: $var1 = "" $var2 = "123" $var3 = "456" $var1 = $var1 + var2; Now that works fine. But when I do that again somewhere else $var1 = $var1 + $var3; The numbers inside the $var1 get scrambled and don't end up in 123456. What am I doing wrong? Link to comment https://forums.phpfreaks.com/topic/69133-basic-combining-strings/ Share on other sites More sharing options...
Aeglos Posted September 13, 2007 Share Posted September 13, 2007 $var1 = $var2 . $var3; That will give you $var1 = 123456. The point operator ( . ) joins two variables, the plus operator simply arithmeticaly adds them, as in: $var1 = 123+456 = 579 Link to comment https://forums.phpfreaks.com/topic/69133-basic-combining-strings/#findComment-347493 Share on other sites More sharing options...
marcus Posted September 13, 2007 Share Posted September 13, 2007 $var = 123; $var .= 456; echo $var; Link to comment https://forums.phpfreaks.com/topic/69133-basic-combining-strings/#findComment-347497 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.