在PHP中,可以使用"."操作符来拼接字符串。例如: ```php $str1 = "Hello"; $str2 = "World"; $result = $str1 . $str2; // 将$str1和$str2拼接起来 echo $result; // 输出: HelloWorld ``` PHP还提供了一种简便的方式来拼接字符串,即双引号字符串中直接插入变量。例如: ```php $name = "John"; $age = 20; $message = "My name is $name and I am $age years old."; echo $message; // 输出: My name is John and I am 20 years old. ``` 这样,变量$name和$age会自动被解析并插入到字符串中。 [2024-02-23 17:25:46 | AI写代码神器 | 381点数解答]