Home > Article > Backend Development > premiere pro cs4 download PHP4 practical application experience 7
Author: Sun Movement
Another type of control statement that has almost the same function as the "if-else" family control statement is PHP's "switch" statement. It will look like this:
------------------------------------------------ -------------------------------------
switch (decision variable)
{
case first The first condition is correct:
do this!
case The second condition is correct:
do this!
case The third condition is correct:
do this!
... Wait...
}
------ -------------------------------------------------- --------------------------
We will make this clearer by rewriting the fortune cookie example above using a "switch" statement:
[cookie.php]
------------------------------------------------- -------------------------------------
< ?
// The deciding variable here is the user Selected date
switch ($day)
{
// First case
case "Monday":
$fortune = "Don't make it simple and effective when you can find a way to make everything complicated and exciting ";
break;
// The second case
case "Tuesday":
$fortune = "Life is the bridge of the game? - You must have used some kind of trick. ";
break;
// The third case.
case "Wednesday":
$fortune = "What can make a sane person live in this world and never go crazy?";
break;
// The fourth case
case "Thursday":
$fortune = " Don't be crazy, be interesting";
break;
// The fourth case
case "Friday":
$fortune = "Just follow the times and go with the trend. When you get promoted, you will find that type is a devil. ";
break;
// If none of the above conditions are met...
default:
$fortune = "Sorry, closed on weekends";
break;
}
?>
< html>
< head> ;
< basefont face="Arial">
< /head>
< body>
Here are your lucky words:
< br>
< b> ;< ? echo $fortune; ?>< /b>
< /body>
< /html>
-------------------------- -------------------------------------------------- ---------
There are two important keywords: the keyword "break" is used to break the "switch" statement structure and immediately move outside the structure block, and then run the lines immediately following the block. The "default" keyword is used to execute a statement that is set when the variables passed to "switch" do not match any of the conditions listed in the statement structure.
The above introduces the premiere pro cs4 download PHP4 practical application experience part 7, including the content of premiere pro cs4 download. I hope it will be helpful to friends who are interested in PHP tutorials.