开发者

How to concat string in PHP [duplicate]

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜