Home  >  Article  >  Backend Development  >  What does link character mean in php

What does link character mean in php

青灯夜游
青灯夜游Original
2022-05-20 11:22:243536browse

In PHP, the link character refers to the symbol for linking strings. Its function is to splice characters, which can splice two or more strings into a new string. There are two types of PHP linkers: 1. "." connector, which is just a simple splicing of strings; 2. ".=" operator, which can be spliced ​​and assigned, and can append the string (variable) on the right to the left.

What does link character mean in php

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

In php, the link symbol refers to the link The symbol of a string is used as a splicing character, which can splice two or more strings into a new string.

For example: Splice the following two strings:

$str1="hello";
$str2="world";

into one string:

helloworld

There are two types of PHP linkers:

  • "." Connector

  • ".=" Operator

1, "." The connector

is a simple splicing of strings. The syntax is:

string1.string2.string3. ······ .stringN

. The operation in the above example can be as follows:

$str1="hello";
$str2="world";
$str=$str1.$str2;
echo $str;

What does link character mean in php

A separator can also be added between the two strings

echo $str1." ".$str2;
echo $str1."-".$str2;

What does link character mean in php

2, ".=" operator

". =” is an assignment operator, which can append the string (variable) on the right side of the operator to the left side to form a new value and then assign it to the left side. Syntax:

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

The ".=" operator is more convenient to splice two strings, but splicing multiple strings at once is not possible. In this case, it is recommended to implement the "." operator.

Example:

$str1="hello";
$str2="world";
$str1.=$str2;
echo $str1;

What does link character mean in php

When using the ".=" operator to splice two strings, you cannot add a separator in the middle.

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of What does link character mean 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