LuciBKen Posted June 22, 2007 Share Posted June 22, 2007 Could any one tell me the real difference in using .= or just =? Quote Link to comment https://forums.phpfreaks.com/topic/56759-really-dumb-question/ Share on other sites More sharing options...
mkosmosports Posted June 22, 2007 Share Posted June 22, 2007 .= will concatenate (join) the already existing string with whatever you specify it to equal...very useful... So for example, $text = "hello"; $text .= " ,my name is"; echo($text), will now be hello ,my name is... Quote Link to comment https://forums.phpfreaks.com/topic/56759-really-dumb-question/#findComment-280301 Share on other sites More sharing options...
Caesar Posted June 22, 2007 Share Posted June 22, 2007 <?php $strvar = "Line one\n"; echo $strvar; /*Will echo... Line one */ ?> <?php $strvar = "Line one\n"; $strvar .= "Line two\n"; $strvar .= "Line three\n"; echo $strvar; /*Will echo... Line one Line two Line three */ ?> Quote Link to comment https://forums.phpfreaks.com/topic/56759-really-dumb-question/#findComment-280305 Share on other sites More sharing options...
chigley Posted June 22, 2007 Share Posted June 22, 2007 .= is used for adding to an existing variable $var = "hello "; $var .= "world"; // hello world = redefines the entire variable $var = "hello "; $var = "world"; // world Quote Link to comment https://forums.phpfreaks.com/topic/56759-really-dumb-question/#findComment-280306 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.