note 107601 deleted from control-structures.intro by tularis
| From: | tularis@php.net | Date: | Tue, 21 Feb 2012 09:23:03 +0000 |
| Subject: | note 107601 deleted from control-structures.intro by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-186255@lists.php.net to get a copy of this message | ||
Note Submitter: jonexman007 at gmail dot com
----
We use the if... else... else if statements to establish conditional logic and evaluate things when
needed in our scripts. Sometimes you have to evaluate values to then give the user the correct
output on page once the variable value is checked.
<?php
$cur_temp = 28; // Current South Pole temperature
if ($cur_temp > 32) { // If temp is greater than 32 degrees F
echo "The icecaps melt, sea levels rise.";
} else if ($cur_temp < -45) { // If temp is less than -45 degrees F
echo "Mammals that live on surface start to die, it is too cold for them to live.";
} else if ($cur_temp < -250) { // If temp is less than -250 degrees F
echo "The entire planet freezes over on the crust, all life on top dies.";
} else { // default last clause, can be removed if needed
echo "Everything is great, and earth conditions are fine for a good balance.";
}
?>
Output: Everything is great, and earth conditions are fine for a good balance.