<html>
<body>
<form action="jisuan.php" method="get">
First: <input type="text" name="n1" />
<select name="fuhao" id="select">
<option value="1"> + </option>
<option value="2"> - </option>
<option value="3"> * </option>
<option value="4"> / </option>
</select>
Two: <input type="text" name="n2" />
<input type="submit" value="=">
</body>
</html>
4.在新建一个文件,写传值的页面
如:jisuan.php
<?php
switch ($_GET["fuhao"])
{
case '1':
$total=$_GET["n1"]+$_GET["n2"];
echo $total;
break;
case '2':
$total=$_GET["n1"]-$_GET["n2"];
echo $total;
break;
case '3':
$total=$_GET["n1"]*$_GET["n2"];
echo $total;
break;
case '4':
if ($_GET["n2"]==0)
{
$total="不能为0";
echo $total;
}
else
{
$total=$_GET["n1"]/$_GET["n2"];
echo $total;
}
break;
default:
break;
}
?>