What does the .= operator mean in PHP?

前端 未结 4 1928
逝去的感伤
逝去的感伤 2021-01-01 08:57

I have a variable that is being defined as

$var .= \"value\";

How does the use of the dot equal function?

4条回答
  •  执念已碎
    2021-01-01 09:31

    the "." operator is the string concatenation operator. and ".=" will concatenate strings.

    Example:

    $var = 1;
    $var .= 20;
    

    This is same as:

    $var = 1 . 20;
    

    the ".=" operator is a string operator, it first converts the values to strings; and since "." means concatenate / append, the result is the string "120".

提交回复
热议问题