note 107601 added to control-structures.intro

From: Date: Tue, 21 Feb 2012 06:52:43 +0000
Subject: note 107601 added to control-structures.intro
Groups: php.notes 
Request: Send a blank email to php-notes+get-186250@lists.php.net to get a copy of this message
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. ---- Server IP: 69.147.83.197 Probable Submitter: 80.239.243.110 ---- Manual Page -- http://www.php.net/manual/en/control-structures.intro.php Edit -- https://master.php.net/note/edit/107601 Del: integrated -- https://master.php.net/note/delete/107601/integrated Del: useless -- https://master.php.net/note/delete/107601/useless Del: bad code -- https://master.php.net/note/delete/107601/bad+code Del: spam -- https://master.php.net/note/delete/107601/spam Del: non-english -- https://master.php.net/note/delete/107601/non-english Del: in docs -- https://master.php.net/note/delete/107601/in+docs Del: other reasons-- https://master.php.net/note/delete/107601 Reject -- https://master.php.net/note/reject/107601 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#186250) next »