Example
Return true if at least one of the statements is true:
html
<?php
if (5 > 3 or 5 > 10) {
echo "true";
} else {
echo "false";
}
?>
Definition and Usage
The or keyword is a logical operator.
Logical operators are used to combine conditional statements.
The return value will be true if any one of the statements returns true, otherwise it will return false.
The difference between or and || is that or has very low precedence, meaning that most other operations get evaluated first.
Related Pages
More Examples
Example
Difference between or and ||. or has lower precedence than the = operator, so the assignment happens first.
html
<?php
$result1 = false || true;
echo "false || true = ";
echo
$result1 ? "true" : "false";
echo "<br>";
$result2 = false or
true;
echo "false or true = ";
echo $result2 ? "true" : "false";
?>