开发者

How to concat string in PHP [duplicate]

开发者 https://www.devze.com 2023-02-18 00:37 出处:网络
This question already has answers here: 开发者_StackOverflow社区 How can I combine two strings together in PHP?
This question already has answers here: 开发者_StackOverflow社区 How can I combine two strings together in PHP? (19 answers) Closed 4 years ago.

I want to do like this:

$string = "";
$string += "lol"; //maybe =+  > tried but both not working

But it isn't working, anyone suggestions? Google isn't making my life easy (cant search characters like = or +)


In PHP, string concatenation is done with the . operator:

$string .= 'lol';

+ is for addition.


$str = "";
while(...){
$str .= "lol.";
}

Replace the ellipses with your loop condition, (+=) is an addition assignment operator that adds the value of the right operand to a variable and assigns the result to the variable.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号