Archive for November 20, 2010

Learn PHP-21 : if… else… else if Statements

Posted: November 20, 2010 in PHP
Tags:

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.

if

<?php $current_temperature = 37; // Current South Pole temperature // Then the if statement will evaluate it for us if ($current_temperature > 32) { // Set things to melt if the temp is exceeding 32(freezing) echo "Doom! The icecaps will melt, sea levels will rise."; } // If the temp is still freezing(32), nothing at all will happen in this script ?>
 

The browser is shown like below

Doom! The icecaps will melt, sea levels will rise.

(more…)