ridiculous Posted March 30, 2008 Share Posted March 30, 2008 When do you want to prefix an equals sign with a period in PHP? For example: $rage .= "My girlfriend cheated on me. With a Mexican."; Link to comment https://forums.phpfreaks.com/topic/98721-the-meaning-of/ Share on other sites More sharing options...
jordanwb Posted March 30, 2008 Share Posted March 30, 2008 $rage .= "My girlfriend cheated on me. With a Mexican."; PHP would then add "My girlfriend cheated on me. With a Mexican." to the end of whatever is in the variable $rage. It's called Concatenation. Link to comment https://forums.phpfreaks.com/topic/98721-the-meaning-of/#findComment-505187 Share on other sites More sharing options...
Barand Posted March 30, 2008 Share Posted March 30, 2008 $str .= $anotherstr; is same as $str = $str . $anotherstr; Link to comment https://forums.phpfreaks.com/topic/98721-the-meaning-of/#findComment-505189 Share on other sites More sharing options...
Bladescope Posted March 30, 2008 Share Posted March 30, 2008 $str .= $anotherstr; is same as $str = $str . $anotherstr; Example $crime = "Professor Plum. "; $crime .= "In the Library. "; $crime .= "With the Candlestick."; print $crime; // Returns: Professor Plum. In the Library. With the Candlestick. It should also be noted that if you use '.=' without declaring the variable beforehand, it generates a notice error. It isn't a major error, but it should be fixed for good practice and for clean scripts. Declaring the variable means just to state it beforehand, i.e. $var; or $var = 'something'; rather than just going straight into an undeclared variable using '.=' Link to comment https://forums.phpfreaks.com/topic/98721-the-meaning-of/#findComment-505202 Share on other sites More sharing options...
ridiculous Posted March 31, 2008 Author Share Posted March 31, 2008 Thanks guys. Great info. Link to comment https://forums.phpfreaks.com/topic/98721-the-meaning-of/#findComment-505232 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.