search
HomeBackend DevelopmentPHP ProblemWhat does php dot mean?

What does php dot mean?

Mar 09, 2023 pm 01:52 PM
phpphp string

In PHP, dot "." means "connection" or "splicing". It is a string connector that 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;". In addition to using "." strings to concatenate strings, there is also the assignment operator ".=" and the syntax "$string1 .= $string2".

What does php dot mean?

The operating environment of this tutorial: windows7 system, PHP8 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;

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;
?>

Output result:

What does php dot mean?

You can see When we use echo for output, we sometimes need some text prompts. At this time, we can use the string concatenator to splice the text strings and variables surrounded by quotation marks together for output, such as the "echo " character After concatenating string 1 and string 2: ".$str3;".

Note:

When using echo to output a string, you can also use curly brackets {$str} to embed variables in the string, such as " Text {$str}Text"; If {} is not used, 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}";
?>

Output result:

What does php dot mean?

Extended knowledge: use assignment operator.=

Except Use the "." operator to concatenate strings, and you can also use the assignment operator ".=" to concatenate strings.

In PHP, you can use the format of "$string1 .= $string2" to concatenate strings. The

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

$string = string1;
$string .= string2;
$string .= string3;
······
$string .= stringn;

Let’s take a look at the following example to understand the .= operator.

<?php
header("Content-type:text/html;charset=utf-8");
$str1="欢迎来到";
echo "字符串1:".$str1;

$str2="PHP中文网";
echo "<br>字符串2:".$str2;

$str1.=$str2;
echo "<br>字符串1和字符串2拼接后:".$str1;
?>

Output results:

What does php dot mean?

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of What does php dot mean?. 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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools