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:
<code class="php">$str1 = "Hello"; $str2 = "World"; $str3 = $str1 . $str2; // 输出:HelloWorld</code>
Concatenate strings and Variables:
<code class="php">$name = "John"; $str = "My name is " . $name; // 输出:My name is John</code>
Connect strings and expressions:
<code class="php">$age = 30; $str = "My age is " . $age . " years old"; // 输出:My age is 30 years old</code>
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!