Home > Backend Development > PHP Problem > What does '.' in php mean?

What does '.' in php mean?

青灯夜游
Release: 2023-03-12 12:04:02
Original
9997 people have browsed it

The dot "." in php means "connection", which refers to the string connector, which can be used to splice two or more strings together to form a new string. ;The specific syntax format is "$string = string1.string2.string3.······.stringN;".

What does '.' in php mean?

The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

In php, click ". " refers to the string concatenation character, which can splice two or more strings into a new string.

The specific syntax format is as follows:

$string = string1.string2.string3. ······ .stringn;
Copy after login

Example:

<?php
header("Content-type:text/html;charset=utf-8");
$str1="欢迎来到";
$str2="PHP中文网";
$str3=$str1.$str2;
echo "字符串1:".$str1;
echo "<br>字符串2:".$str2;
echo "<br>字符串1和字符串2拼接后:".$str3;
?>
Copy after login

Output result:

What does . in php mean?

Instructions: When using echo to output a string, you can also use curly brackets {$str} to embed variables in the string, such as "literal{$str}literal"; if you do not use { } You can also use word segmentation characters to separate variables and text. Word segmentation characters are generally spaces, punctuation marks, etc.

<?php
header("Content-type:text/html;charset=utf-8");
$str1="欢迎来到";
$str2="PHP中文网";
$str3=$str1.$str2;
echo "字符串1:".$str1;
echo "<br>字符串2:$str2";
echo "<br>字符串1和字符串2拼接后: {$str3}";
?>
Copy after login

Output result:

What does . in php mean?

In javascript, we can use " " to splice strings, but in PHP, the " " sign can only do arithmetic operator, but cannot be used as a string operator; then can only the "." operator be used to concatenate strings? No, you can also use the assignment operator ".=". The

.= operator appends the characters on the right to the left. Its syntax is:

$string = string1;
$string .= string2;
$string .= string3;
······
$string .= stringn;
Copy after login

Recommended learning: "PHP Video Tutorial"

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

Related labels:
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