How to concat string in PHP [duplicate]

2020-02-05 06:10发布

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 +)

标签: php loops
2条回答
别忘想泡老子
2楼-- · 2020-02-05 07:01

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

$string .= 'lol';

+ is for addition.

查看更多
我命由我不由天
3楼-- · 2020-02-05 07:12
$str = "";
while(...){
$str .= "lol.";
}

Input or place the ellipses with your loop condition, += is an add and increment operator.

查看更多
登录 后发表回答