$string1 = 'Hello';
$string2 = 'World!';
$string3 = $string1.' '.$string2;
echo $string3; // prints - Hello World!
string1 = 'Hello'
string2 = 'World!'
string3 = string1 + ' ' + string2
Both of these examples are actually concatenating three strings – ‘Hello’, ‘ ‘, and ‘World!’. You can use variables, literals or constants.
To combine a string to itself in PHP, you can also do this:
$string1 = "Hello";
$string2 = "World!";
$string1 .= ' '.$string2;
echo $string1; //prints Hello World!
The .= operator concatenates the string after the operator to the end of the string on the left of the operator. In this example, the two strings (‘ ‘ and $string2) are concatenated to each other and then concatenated to $string1.