0

PHP. Can somebody explain me what

|=

means in the following lines of code?

$mark = true;
$options = FT_UID;
if(!$mark) { 
  $options |= FT_PEEK;
}

I've read | is a bitwise operation which operates on bits but I still don't get it..

Giacomo Scarpino
  • 599
  • 3
  • 17

1 Answers1

0

It is read "OR equals." So it ors the lvalue with the rvalue and assigns to the lvalue.

$a = 0;
..
$a |= $b

is the same as

$a = $a | $b
Scott C Wilson
  • 19,102
  • 10
  • 61
  • 83