Correcting teacher:灭绝师太
Correction status:qualified
Teacher's comments:
// 定义3个变量
$a = 4; //操作数1
$b = 2; //操作数2
$res = 0; //保留计算结果
//定义+ - / 字符串
$calc =’+’;
//加法运算
if ($calc === ‘+’){
$res = $a + $b;
echo $a.$calc.$b.’=’.$res;
}
//减法运算
elseif ($calc === ‘-‘){
$res = $a - $b;
echo $a.$calc.$b.’=’.$res;
}
//乘法运算
elseif ($calc === ‘‘){
$res = $a * $b;
echo $a.$calc.$b.’=’.$res;
}
//除法法运算
elseif ($calc === ‘/‘){
$res = $a / $b;
echo $a.$calc.$b.’=’.$res;
}
else {
echo ‘超过我的计算能力!’;
}
?>