LuciBKen Posted June 22, 2007 Share Posted June 22, 2007 Could any one tell me the real difference in using .= or just =? 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... 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 */ ?> 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 Link to comment https://forums.phpfreaks.com/topic/56759-really-dumb-question/#findComment-280306 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.