25

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

Nayeem Azad
  • 597
  • 4
  • 20
user657601
  • 267
  • 1
  • 3
  • 4

2 Answers2

73

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

$string .= 'lol';

+ is for addition.

Marc B
  • 348,685
  • 41
  • 398
  • 480
1
$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.

Marcel
  • 109
  • 3
  • 6