$a |= $b

Binary or assignment

Apply a binary "or" operation and assign the first variable to the result.

Tags
// Binary representation: 1100
$a = 12; 

// Binary representation: 1010
$b = 10; 

// Binary result: 1110
// 1 OR 1 = 1
// 1 OR 0 = 1
// 0 OR 1 = 1
// 0 OR 0 = 0
$a |= $b; 

null coalescing

What is this? Who are you!?

PHP Operators is a reference guide for operators old and new in the PHP programming language. We're SPATIE, a web development agency from Belgium. Besides client work we like to contribute to the open source community and make fun projects like this one.