PHP入門でswitch文の利用方法
PHPコード:
<?php
function kesuan($m,$rum,$n){
switch($rum){
case '+’:
echo $r=$m + $n;
break;
case “-“:
echo $r=$m – $n;
break;
case “*":
echo $r=$m * $n;
break;
case “/":
echo $r=$m / $n;
break;
}
}
kesuan(2,’+’,8);
echo “<br>";
kesuan(6,’*’,9);
echo “<br>";
kesuan(18,’/’,9);