Home >Backend Development >PHP Problem >Usage of . in php

Usage of . in php

藏色散人
藏色散人Original
2021-02-07 09:08:244522browse

"." 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.

Usage of . in php

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn