Home >Backend Development >PHP Problem >Usage of . in php
"." in php is a character operator, which is used to connect two strings. How to use it: first create a PHP sample file; then define two variables; finally pass "$result.$ result" method to connect the two variables.
The operating environment of this tutorial: Windows 7 system, PHP version 7.1, DELL G3 computer.
php variable and string connector-dot
Connector-dot is also an operator in itself. Its real name should be "character operator". Its function is to concatenate two strings.
echo character . variable . character;
//The dot connects three values into one and runs normally.
Example 1:
1.字符串+变量+字符串 echo("<!--".$result."-->"); 2.变量+变量 echo($result.$result); 3.字符串+变量 echo("a".$result);
Example 2
.
Concatenation
$txt1 = "Hello" $txt2 = $txt1 . " world!"
Now $txt2 contains "Hello world!"
Output:
Hello world!
The above is the detailed content of Usage of . in php. For more information, please follow other related articles on the PHP Chinese website!