我正在尝试用PHP创建一个计算器。所有其他运算符都在工作(例如:+,_,*,/),但只有模数%运算符不工作。请解决这个问题。
<form method="get">
<input type="text" name="Number1" placeholder="Enter Number One">
<input type="text" name="Number2" placeholder="Enter Number Two">
<select name="operator">
<option >Division</option>
<option >Modulation</option>
</select>
<button type="submit" name="submit">Calculate</button>
</form>
php代码在这里:
<?php
echo "<br> Your Result is : ";
if(isset($_GET['submit'])){
$result1=$_GET['Number1'];
$result2=$_GET['Number2'];
$operator=$_GET['operator'];
switch($operator){
case 'Division':
echo $result1/$result2;
break;
case 'Modulation':
echo $result1 % $result2;
break;
}
}
?>