PHP - Logical or: ||, or
Logical OR works as follows: just in case it's the result false if both inputs are false, in all other cases the result is true. In next table you can find all possibilities:a | b | x |
---|---|---|
False | False | False |
False | True | True |
True | False | True |
True | True | True |
||
Description
par1 || par2
Input
- par1 - Logical value
- par2 - Logical value
Output
- Result - Logical value
Examples
PHP
In the source code you can find the equivalent of the above table, for easier orientation at the end of each line is a comment which shows the result.$a1 = false || false; // a1 = false
$a2 = false || true; // a2 = true
$a3 = true || false; // a3 = true
$a4 = true || true; // a4 = true
PHP
Even one example in what situations we can use the operation logical or:($b || $c) || $a
$a || true
$a>1 || $a<100
PHP
Other pieces of example codes:$j > 128 || false
$a || true
(10 >$a || $a<5)
or
Description
par1 or par2
Input
- par1 - Logical value
- par2 - Logical value
Output
- Result - Logical value
Examples
PHP
In the source code you can find the equivalent of the above table, for easier orientation at the end of each line is a comment which shows the result.$a1 = false || false; // a1 = false
$a2 = false || true; // a2 = true
$a3 = true || false; // a3 = true
$a4 = true || true; // a4 = true
PHP
Even one example in what situations we can use the operation logical or:($b || $c) || $a
$a || true
$a>1 || $a<100
You can find it in the following collections: logical operators
Logical or in another programming language:
Differences to: