PHP MYSQL - Operators - 5.5 Logical Operators
PHP MYSQL - Operators - 5.5 Logical Operators
PHP Logical Operators
The PHP logical operators are used to combine conditional statements.
Operator | Name | Example | Result | |
---|---|---|---|---|
and | And | $x and $y | True if both $x and $y are true | |
or | Or | $x or $y | True if either $x or $y is true | |
xor | Xor | $x xor $y | True if either $x or $y is true, but not both | |
&& | And | $x && $y | True if both $x and $y are true | |
|| | Or | $x || $y | True if either $x or $y is true | |
! | Not | !$x | True if $x is not true |
<!DOCTYPE html>
<html>
<body>
<?php
$x = 10;
$y = 20;
if ($x == 100 and $y == 50) {
echo "Vesrn Technologies!";
}
?>
</body>
</html>
Output:
Vesrn Technologies
Logical operators are widely used when it necessary, dear student you can try remaining operators with your own.