PHP has two operators that are specially designed for strings.
They are concatenation (.) and concatenation assignment (.=).
The concatenation operator concatenates two strings. Eg: $str1.$str2.
The concatenation assignment operator(.=) assigns one string to another. Eg: $str1=$str2.
Operator | Description | Example | Result |
---|---|---|---|
. |
Concatenation | $str1 . $str2 |
Concatenation of $str1 and $str2 |
.= |
Concatenation assignment | $str1 .= $str2 |
Appends the $str2 to the $str1 |
Welcome to : aimtocode! Welcome to : aimtocode!