- PHP 7 Tutorial
- PHP 7 - Home
- PHP 7 - Introduction
- PHP 7 - Performance
- PHP 7 - Environment Setup
- PHP 7 - Scalar Type Declarations
- PHP 7 - Return Type Declarations
- PHP 7 - Null Coalescing Operator
- PHP 7 - Spaceship Operator
- PHP 7 - Constant Arrays
- PHP 7 - Anonymous Classes
- PHP 7 - Closure::call()
- PHP 7 - Filtered unserialize()
- PHP 7 - IntlChar
- PHP 7 - CSPRNG
- PHP 7 - Expectations
- PHP 7 - use Statement
- PHP 7 - Error Handling
- PHP 7 - Integer Division
- PHP 7 - Session Options
- PHP 7 - Deprecated Features
- PHP 7 - Removed Extensions & SAPIs
- PHP 7 Useful Resources
- PHP 7 - Quick Guide
- PHP 7 - Useful Resources
- PHP 7 - Discussion
Difference between the | and || or operator in php
'|' Bitwise OR operator
'|' operator is a bitwise OR operator and is used to set the bit to 1 if any of the corresponding bit is 1.
'||' Logical Or operator
'||' is a logical Or operator and works on complete operands as whole.
Following example, shows usage of '|' vs '||' operators.
<!DOCTYPE html> <html> <head> <title>PHP Example</title> </head> <body> <?php $x = 1; // 0001 $y = 2; // 0010 print('$x | $y = '); echo $x | $y; print("<br/>"); print('$x || $y = '); echo $x || $y; ?> </body> </html>
$x | $y = 3 $x || $y = 1
- Related Articles
- Difference between the and$ operator in php
- Difference between !== and ==! operator in PHP
- Difference between the AND and && operator in php
- Difference between the Ternary operator and Null coalescing operator in php
- Comparison between "&&" and "AND" operator in PHP.
- What is the difference Between AND, OR operator in MySQL while Retrieving the Rows?
- Difference between "new operator" and "operator new" in C++?
- Difference between == and is operator in python.
- Difference between concat() and + operator in Java
- Explain difference between == and is operator in Python.
- Difference between != and is not operator in Python
- What is the difference between the dot (.) operator and -> in C++?
- Difference between gettype() in PHP and get_debug_type() in PHP 8