亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Nested if...else...elseif structure of PHP process control

I still remember that we talked about an example of classmate Wang Sixong at the beginning of this chapter:

Wang is a person whose life is extremely full of entertainment and enjoyment. What he did when he arrived in Beijing or Dalian, what he did after arriving, is as follows:

Arrived in the middle of the night, first went to a nightclub to attend a masquerade party
Arrive in the morning and take a bath in the hotel
Arrive at noon and have a portion of Kobe beef
Arriving at night, I always like to go to friends to talk about the loneliness in my heart

Let’s learn about his grammar rules [Knowledge point requirements: silent writing]

<?php
if(判斷語句1){
    執(zhí)行語句體1
}elseif(判斷語句2){
    執(zhí)行語句體2
}else if(判斷語句n){
        執(zhí)行語句體n
}else{
        最后的else語句可選
}

//后續(xù)代碼
?>

The above structure means:
If the value of statement 1 is true, execute statement body 1. After execution is completed, enter the subsequent code segment.
Otherwise, go to the following judgment statement 2 (elsif). If judgment statement 2 is true, statement body 2 will be executed.
Otherwise, go to the following judgment statement n (elsif). If judgment statement 2 is true, execute statement body n.
If none match, execute the else statement. This kind of loop nesting can not contain else statements, that is, it can only contain if and elseif statements.

Note: elseif() can also be written as else if()

We express the above code clearly in the form of a flow chart as shown below:
2015-08-08/55c5966bd7af5

We can express the example of Mr. Wang Sixong through PHP code. The result of the code representation is as follows:

<?php
//定義一個隨機變量,抵達時間,隨機0點至23點
$dida = rand(0,23);

if($dida > 6 && $dida < 10){
    echo '我愛泡澡';
}else if($dida >10 && $dida < 14){
    echo '吃神戶牛肉';
}else if($dida >=19 && $dida < 22){
    echo '找一個朋友聊聊內(nèi)心的寂寞';
}elseif($dida > 22 && $dida <= 23){
    echo '泡澡';

}elseif($dida >= 1 && $dida <3){
     echo '泡澡';
}else{
    echo '睡覺或者工作';
}


?>

Assignment:
Write a web page cj.html , submit the score segment to the panduan.php page in post mode. The score range and displayed results are as follows, and the requirements are as follows:

  1. 0----Below 60, failed
  2. 60---70 passed, please work hard
  3. 70---80 Not bad
  4. 80---90 There is hope to go to Tsinghua University
  5. 90---100 You have no hope in this life
  6. 100 Even less I hope
  7. 100 points or more Einstein is reincarnated, Smecta!
  8. is not a numeric type or less than 0. Please enter the correct score.
Continuing Learning
||
<?php //定義一個隨機變量,抵達時間,隨機0點至23點 $dida = rand(0,23); if($dida > 6 && $dida < 10){ echo '我愛泡澡'; }else if($dida >10 && $dida < 14){ echo '吃神戶牛肉'; }else if($dida >=19 && $dida < 22){ echo '找一個朋友聊聊內(nèi)心的寂寞'; }elseif($dida > 22 && $dida <= 23){ echo '泡澡'; }elseif($dida >= 1 && $dida <3){ echo '泡澡'; }else{ echo '睡覺或者工作'; } ?>
submitReset Code