1 <?php 2 function grade($grade){ 3 switch (true) { 4 case $grade>=90: 5 echo ‘A‘; 6 break; 7 case $grade>=80: 8 echo ‘B‘; 9 break; 10 case $grade>=70: 11 echo ‘C‘; 12 break; 13 case $grade>=60: 14 echo ‘D‘; 15 break; 16 default: 17 echo ‘E‘; 18 break; 19 } 20 21 } 22 grade(95); 23 grade(85); 24 grade(75); 25 grade(65); 26 grade(55); 27 28 //ABCDE 29 ?>
时间: 2024-10-08 04:03:40