The symbol to connect two strings in PHP is . (dot), which can be used to connect strings, variables and expressions. It should be noted that the connector is left associative and can connect multiple data types, but type conversion is required.
The symbol to connect two strings in PHP:
.
(dot)
The symbol that connects two strings in PHP is.
(dot). It is used in the following scenarios:
Concatenate two strings:
$str1 = "Hello"; $str2 = "World"; $str3 = $str1 . $str2; // 输出:HelloWorld
Concatenate strings and Variables:
$name = "John"; $str = "My name is " . $name; // 输出:My name is John
Connect strings and expressions:
$age = 30; $str = "My age is " . $age . " years old"; // 输出:My age is 30 years old
Notes:
The above is the detailed content of What is the symbol to connect two strings in php. For more information, please follow other related articles on the PHP Chinese website!