开发者

How can I use the += operator in PHP for a string? [duplicate]

This question already has answers here: How can I combine two string开发者_Go百科s together in PHP? (19 answers) Closed 8 years ago.

How can I use the += operator for a string in PHP?

Below is a Java example:

String str = "";

str += "some value";
str += "some more values";

The above example concatenates and assign all values to the str object.

How can I achieve this in PHP?


You are searching for .=:

$str = "";
$str .= "some value";


 $str .= "some value"; 
 $str .= "some more values";


Either:

$str = $str + "stuff";

Or:

$str .= "stuffsicles";
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜