Author: Sun Sports
Now, you've learned that PHP allows you to nest conditional statements. However, if you look at the example that is used to demonstrate this concept, you will agree that it is both complex and frightening.
--------------------------------------------------------------------------------
<?
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 that allow you to aggregate conditional statement descriptions. The following tables clearly illustrate these:
Assume $delta = 12 and $omega = 9
Operator
Significance
Example
Results
&&
and
$delta = = $gamma && $delta > $omega
True
$delta && $omega < $omega
False
||
OR
$delta = = $gamma | | $delta < $omega
True
$delta > $gamma | | $delta < $omega
False
!
Not
! $delta
False
< =
Less than or equal to
$delta < = $omega
False
Well, we can rewrite the code of the above example with a logical operator, do you think the following statement is simpler?
--------------------------------------------------------------------------------
<?
if ($day = = "Thursday" && $time = = "a" && $place = = "Italy")
{
$lunch = "pasta";
}
--------------------------------------------------------------------------------
Is it simple and elegant? Yes
The above describes the Adobe photoshop cs4 PHP4 practical application experience 6, including the Adobe Photoshop cs4 aspect of the content, want to be interested in PHP tutorial friends helpful.