PHP:第二章——PHP中的switch语句

<?php
header("Content-Type:text/html;charset=utf-8");
/*
switch语句:
*/
//例1:
/*$i = 99;
switch ($i) {
    case 0:
        echo "i equals 0";
        break;
    case 1:
        echo "i equals 1";
        break;
    case 2:
        echo "i equals 2";
        break;
    default:
        echo "OK"    ;
}*/
//例2:
 $i = 50;
switch (true) {
    case $i<60:
        echo "不及格";
        break;
    case $i<80:
        echo "良好";
        break;
    case $i<100:
        echo "优秀";
        break;
    default:
        echo "请输入正确的成绩范围0-100"    ;
}
?>

 

posted @ 2017-07-05 06:54  生如逆旅,一苇以航  阅读(166)  评论(0编辑  收藏  举报