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
  • 7,115
  • 14
  • 48
  • 90

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,032
  • 1
  • 18
  • 42