1

Possible Duplicate:
Reference - What does this symbol mean in PHP?

I have seen references to = (of course) but also .= and ^=. What are those two for? Are there others?

Community
  • 1
  • 1
JDelage
  • 13,036
  • 23
  • 78
  • 112
  • 8
    http://php.net/manual/en/language.operators.assignment.php – Pekka Jun 28 '11 at 21:28
  • 3
    And this valuable addition in the comments: http://www.php.net/manual/en/language.operators.assignment.php#40084 – Pekka Jun 28 '11 at 21:29
  • Thanks Pekka - that second comment answers the question. In my defense, I ran a search on SO, but I don't think the search engine takes the `.=` symbol into consideration. – JDelage Jun 28 '11 at 21:59

2 Answers2

1

^= 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.

1

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.

Steve Wang
  • 1,814
  • 1
  • 16
  • 12