开发者

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

开发者 https://www.devze.com 2023-03-15 03:40 出处:网络
This question already has answers here: How can I combine two string开发者_Go百科s together in PHP?
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

精彩评论

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