代码不会为我生成计算结果..任何人都可以帮助我吗?
HTML正确显示,我可以输入常量,它们会在URL中更新。 PHP GET函数似乎正在工作,但在页面上没有产生任何结果。
<form>
<input type="text" name="num1" placeholder="Constant">
<input type="text" name="num2" placeholder="Constant">
<select name="Operator">
<option>Select Option</option>
<option>Add</option>
<option>Subtract</option>
<option>Multiply</option>
<option>Divide</option>
</select>
<br>
<br>
<button type="Submit" name="Submit" value="Submit">Calculate</button>
</form>
<p>The answer is: </p>
if (isset($_GET['Submit'])) {
$result1 = $_GET['num1'];
$result2 = $_GET['num2'];
$operator = $_GET['Operator'];
switch ($operator) {
case 'Select Option':
echo "Error";
break;
case 'Add':
echo $result1 + $result2;
break;
case 'Subtract':
echo $result1 - $result2;
break;
case 'Multiply':
echo $result1 * $result2;
break;
case 'Divide':
echo $result1 / $result2;
break;
}}