6

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
  • 120
  • 1
  • 8

2 Answers2

9

This is bitwise OR operator

$var1 |= $var2; is equal to $var1 = $var1 | $var2;
dhi_m
  • 1,185
  • 10
  • 20
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,162
  • 4
  • 28
  • 54
  • 3
    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