Author: Sun Movement
Now, you have understood that PHP allows you to nest conditional statements. However, if you look at the example used to demonstrate this concept you will agree that it is both complex and scary.
----------------------------------------------- ----------------------------------
if ($day == "Thursday" )
{
if ($time == "12")
{
if ($place == "Italy")
{
$lunch = "pasta";
}
}
}
?>
---------------------------------- --------------------------------------------------
Fortunately, in addition to the comparison operators that we can already use without any restrictions, PHP also provides some logical operators to allow you to group conditional statement descriptions. The following table shows this clearly:
Assume $delta = 12 and $omega = 9
Operator
Meaning
Example
Result
&&
AND
$delta == $gamma && $delta > $omega
True
$delta && $omega False
||
OR
$delta == $gamma | | $delta True
$delta > $gamma || $delta False
!
NOT
!$delta
False
Less than or equal to
$delta