The operator for concatenating strings in PHP is dot (.), which concatenates two string values together to form a new string, applicable to any string value, and the connection result is a new character String has higher priority than the assignment operator. It can be used to connect multiple strings continuously, and can also connect strings with other data types (non-string values will be converted to strings).
String concatenation operator in PHP
The operator used to concatenate strings in PHP is dot ( .
). It concatenates two string values together to form a new string.
The syntax of this operator is as follows:
<code>$new_string = $string1 . $string2;</code>
Example:
$str1 = "你好"; $str2 = "世界"; $new_str = $str1 . $str2; // 输出:你好世界 echo $new_str;
A few points to note:
=
), which means $new_str = $str1 $str2;
will result in a syntax error. $str3 = $str1 . $str2 . "!"
will create a new string containing three concatenated strings. The above is the detailed content of The concatenation operator for strings in php is. For more information, please follow other related articles on the PHP Chinese website!