PHP String Concatenation: The Dot Operator Method

In PHP, you can concatenate strings using the dot (.) operator. The code example is shown below:

$str1 = "Hello";
$str2 = "World";
$result = $str1 . ", " . $str2; // 字符串拼接赋值
echo $result; // 输出:Hello, World

In the example above, concatenate two string variables together using the dot operator and assign the result to the $result variable. Then, output the result using an echo statement.

bannerAds