PHP switch Statement |
Can you show ho to write following script using PHP switch statement? $grade="C"; if ($grade=="A"){ echo "Marks Range: 80-100";} elseif ($grade=="B"){ echo "Marks Range: 60-79";} elseif ($grade=="C"){ echo "Marks Range: 40-59";} elseif ($grade=="W"){ echo "Marks Range: 0-39";} else{ echo "Invalid Grade";} |
By : vinuli Email : vinuli@tekstart.lk |
Date/time : 2021-08-14 |
ID | 1 |
Name | Sisira Palihakkara |
sisiraedck@gmail.com | |
Answer | $grade="C"; switch ($grade){ case "A": echo "Marks Range: 80-100"; break; case "B": echo "Marks Range: 60-79"; break; case "C": echo "Marks Range: 40-59"; break; case "W": echo "Marks Range: 0-39"; break; default : echo "Invalid Grade"; } |
Date/Time | 2021-08-14 |