What are the different assignment operators in PHP, how do they differ [duplicate]
Possible Duplicate:
Reference - What does this symbol mean in PHP?
I have seen referenc开发者_Python百科es to =
(of course) but also .=
and ^=
. What are those two for? Are there others?
^=
is a bitwise operator and .=
is a string operator. Both are assignment operators, as they set the value of a variable after evaluating.
The former sets the value of the variable to a XOR of the expression. The latter concats the expression onto the variable.
Many of the binary operators (e.g. +, -, *, /) can be used in conjunction with = as shorthand for assigning values. Essentially, x += 4 is equivalent to x = x + 4.
精彩评论