问题
I am new to PHP. I need to know how to use += operator for string in PHP. Below is Java example:
String str = "";
str += "some value";
str += "some more values";
the above example concatenates and assign all values to str
object.
Can somebody tell me how to achieve this in PHP?
回答1:
You are searching for .=:
$str = "";
$str .= "some value";
回答2:
$str .= "some value";
$str .= "some more values";
回答3:
Either:
$str = $str + "stuff";
Or:
$str .= "stuffsicles";
来源:https://stackoverflow.com/questions/6476940/how-can-i-use-operator-in-php-for-string