0

I have a question regarding the different usage of & in the following two examples:

$x = &$b; // which I know what it does

But what about this one:

$x &= get_instance();
Mostafa Talebi
  • 8,010
  • 15
  • 54
  • 97

1 Answers1

1

&= is the "bitwise and"-assignment operator. In PHP

$a &= $b;

is the same as

$a = $a & $b;

"bitwise and" means that two corresponding bits of two arguments are evaluated using the and-operator. If the arguments are not integers, they are converted to integer values first. For details you can refer to the php manual.

WeSee
  • 2,584
  • 1
  • 25
  • 51