Author: Sun Sports
PHP also gives you a way to deal with a variety of possible ways-the "IF-ELSEIF-ELSE" structure. A typical "IF-ELSEIF-ELSE" structure statement would look like this:
--------------------------------------------------------------------------------
if (first condition is correct)
{
Do this!
}
ElseIf (second condition is correct)
{
Do this!
}
ElseIf (the third condition is correct)
{
Do this!
}
... Wait a minute...
Else
{
Do this!
}
--------------------------------------------------------------------------------
Here is an example that shows how to use it:
--------------------------------------------------------------------------------
< html>
< head>
< style type= "Text/css" >
td {Font-family:arial;}
</style>
< body>
< font face= "Arial" size= "+2" >
Amazing Lucky Cookie Production program
</FONT>
< form method= "GET" action= "cookie.php" >
< table cellspacing= "5" cellpadding= "5" border= "0" >
< tr>
< TD align= "Center" >
Please select a date
</td>
< TD align= "right" >
< select Name= "Day" >
< option value= "Monday" >monday
< option value= "Tuesday" >tuesday
< option value= "Wednesday" >wednesday
< option value= "Thursday" >thursday
< option value= "Friday" >friday
< option value= "Saturday" >saturday
< option value= "Sunday" >sunday
</select>
</td>
</tr>
< tr>
< tr>
< TD colspan= "2" align= "Center" >
< input type= "submit" value= "click me!" >
</td>
</tr>
</table>
</form>
</body>
--------------------------------------------------------------------------------
You will see that this simple form allows you to choose a day of the week. The real processing work is done by the PHP script "cookie.php" after submission.
--------------------------------------------------------------------------------
<?
if ($day = = "Monday")
{
$fortune = "Do not make it simple and effective when you can find a complex and wonderful way to make everything happen."
}
ElseIf ($day = = "Tuesday")
{
$fortune = "Life is the bridge of the game?"-you must have some kind of inventions. ";
}
ElseIf ($day = = "Wednesday")
{
$fortune = "What makes a sane person live in this world and never go mad?" ";
}
ElseIf ($day = = "Thursday")
{
$fortune = "Don't be crazy, be funny";
}
ElseIf ($day = = "Friday")
{
$fortune = "Just follow the times, along the lines of the atmosphere, and when you get promoted you will find that the type is a demon." ";
}
Else
{
$fortune = "Sorry, the weekend is closed";
}
?>
< html>
< head>
< Basefont face= "Arial" >
< body>
Is this your <? Echo $day;?> 's lucky words:
< br>
< b><? echo $fortune;?></b>
</body>
--------------------------------------------------------------------------------
In this case, we use control sentences to assign different lucky words to each day.
There is one important point to note-when an "if" statement in the structure is found to be true, PHP executes the corresponding code, ignoring the "if" statement in the rest of the structure, and immediately jumps out of the "IF-ELSEIF-ELSE" structure, executing the line following the entire structure.
The above describes the live football 8 International version of the download PHP4 practical application Experience 5, including the live Soccer 8 International download content, I hope to be interested in PHP tutorial friends helpful.