Mostafa Talebi
Mostafa Talebi

Reputation: 9183

PHP different usage of reference sign &

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();

Upvotes: 0

Views: 43

Answers (1)

WeSee
WeSee

Reputation: 3762

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

Upvotes: 1

Related Questions