With logical operators, we can make multiple comparisons into if. Let’s show this example that we have given in logical operators using if.
<?php
$a = 10;
if($a > 0 && $a < 100) {
echo '$a variable is between 0-100';
}
?>
Here, if the variable $a
is greater than 0 and $a
is less than 100, we said run the following codes. And since we give 10 to the value of the variable $a
, it will write the variable $a
is between 0-100 on the screen.
If the conditions are not met, the codes we enclose in {…} parentheses will not work.