php switch判断一个数所在的范围

时间:2024-02-19 21:06:58
<?php
header("content-type:text/html;charset=utf8");
$score=70;
switch($score) 
{
  case $score>=90 && $score<=100:
    echo "优秀<br>";
    break;
 case $score>=80 && $score<90:
    echo "良好<br>";
    break;
 case $score>=70 && $score<80:
    echo "中等<br>";
    break;
 case $score>=60 && $score<70:
    echo "及格<br>";
    break;
 case $score>=0 && $score<60:
    echo "不及格<br>";
    break;
 default:
    echo"成绩输入错误<br>";
}
?>