8

I don't know what is the meaning of "|=" in php. Searching Google doesn't help. Please someone explain exactly what they do.

My Question is meaning of "|=" not "!=" ?

I have already search "Reference - What does this symbol mean in PHP?" but i did't get my answer.

Community
  • 1
  • 1
SAR
  • 140
  • 1
  • 8

2 Answers2

14

This is bitwise OR operator

$var1 |= $var2; is equal to $var1 = $var1 | $var2;
dhi_m
  • 1,235
  • 12
  • 21
2

Its a bitwise OR assignment operator. See PHP menual enter image description here

$var1 |= $var2 //it means $var1 = $var1 or $var2
Md. Sahadat Hossain
  • 3,210
  • 4
  • 32
  • 55
  • 4
    This answer is confusing "`//it means $var1 = $var1 or $var2`" in your comment the `or` has the same result as using `||` which is a **logical OR operators**. Whereas `|` is, as you said, a **bitewise OR assignment operator**. Ex : `echo 11 | 12` returns **15** and `echo 11 or 12` will returns **true** – Clément Baconnier Mar 21 '19 at 22:34