0

I know of || operator in php. However friend of mine experimented with single line | and got some strange results. Can anyone explain logic behind this mysterious operator? Is it just some bug or does it have a meaning? Examples: $a =7; $b =4; echo $a | $bj; Result is 7

$a =4; $b =7; echo $a | $bj; Result is also 7

$a =2; $b =9; echo $a | $b; Result is 11

alenphp
  • 5
  • 2
  • 6
  • 2
    It's the [Inclusive Or](http://php.net/manual/en/language.operators.bitwise.php) operator. – stuartd Dec 05 '14 at 00:10
  • The [accepted answer](http://stackoverflow.com/a/13812082/43846) on the original post explains very well what it does. If you don't know what the pipe character is called, it is hard to search for it.. – stuartd Dec 05 '14 at 00:19

1 Answers1

0

It's a bitwise logical operator for "inclusive or". Exclusive or = "^".

Jay Sudo
  • 99
  • 1
  • 2