开发者

What are the different assignment operators in PHP, how do they differ [duplicate]

开发者 https://www.devze.com 2023-03-15 21:05 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: Reference - What does this symbol mean in PHP?
This question already has answers here: Closed 11 years ago.

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.

0

精彩评论

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