Home > Backend Development > PHP Problem > What does link character mean in php

What does link character mean in php

青灯夜游
Release: 2023-03-16 07:54:01
Original
3595 people have browsed it

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

into one string:

helloworld
Copy after login

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
Copy after login

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

$str1="hello";
$str2="world";
$str=$str1.$str2;
echo $str;
Copy after login

What does link character mean in php

A separator can also be added between the two strings

echo $str1." ".$str2;
echo $str1."-".$str2;
Copy after login

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

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

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!

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