PHP String Concatenation: Syntax & Examples

In PHP, string concatenation can be achieved using the . operator. For example:

$str1 = "Hello";
$str2 = "World";

$combinedStr = $str1 . " " . $str2;
echo $combinedStr; // 输出:Hello World

In the example above, we used the concatenation operator to join two strings together. It should be noted that the concatenation operator can only be used for joining strings and not for other data types.

bannerAds