Correcting teacher:PHPz
Correction status:qualified
Teacher's comments:
<form action="1.php" method="post">
<input type="number" name="num1" id="num1">
<input type="number" name="num2" id="num2">
<select name="fu">
<option value="+">+</option>
<option value="-">-</option>
<option value="*">*</option>
<option value="/">/</option>
</select>
<button>提交</button>
</form>
<?php
if(!empty($_POST['num1'])){
$num1=floatval($_POST['num1']);
$num2=floatval($_POST['num2']);
$fu=$_POST['fu'];
}
if(!empty($_POST['num1'])){
switch ($fu) {
case '+':
echo $num1+$num2;
break;
case '-':
echo $num1-$num2;
break;
case '*':
echo $num1*$num2;
break;
case '/':
echo $num1/$num2;
break;
}
}
?>