How can I use += operator in PHP for String [duplicate]

杀马特。学长 韩版系。学妹 提交于 2019-12-02 05:01:37

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!