温馨提示×

PHP中如何连接两个字符串

PHP
小樊
81
2024-08-21 18:15:26
栏目: 编程语言

在PHP中连接两个字符串可以使用.操作符或者concat()函数。示例如下:

使用.操作符:

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

使用concat()函数:

$str1 = "Hello";
$str2 = "World";
$result = concat($str1, " ", $str2);
echo $result; // 输出:Hello World

0