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

Usage of . in php

藏色散人
Release: 2023-03-08 06:04:01
Original
4560 people have browsed it

"." 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);
Copy after login

Example 2

.Concatenation

$txt1 = "Hello" 
$txt2 = $txt1 . " world!"
Copy after login

Now $txt2 contains "Hello world!"

Output:

Hello world!
Copy after login

The above is the detailed content of Usage of . in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template