PHP字符串拼接的方法有以下几种:
$str1 = "Hello";
$str2 = "World";
$result = $str1 . $str2;
echo $result; // 输出:HelloWorld
$name = "John";
$age = 25;
$result = "My name is $name and I am $age years old.";
echo $result; // 输出:My name is John and I am 25 years old.
$name = "John";
$age = 25;
$result = sprintf("My name is %s and I am %d years old.", $name, $age);
echo $result; // 输出:My name is John and I am 25 years old.
$str = "Hello";
$str .= " World";
echo $str; // 输出:Hello World
$array = array("Hello", "World");
$str = implode(" ", $array);
echo $str; // 输出:Hello World