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
  • 657
  • 5
  • 20
user657601
  • 267
  • 1
  • 3
  • 4

2 Answers2

75

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

$string .= 'lol';

+ is for addition.

Marc B
  • 356,200
  • 43
  • 426
  • 500
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
  • 139
  • 2
  • 6