Jump to content

The Meaning of .=


ridiculous

Recommended Posts

$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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.