Heim > Fragen und Antworten > Hauptteil
如题,源码如下
<!DOCTYPE html>
<html>
<head>
简易计算器
</head>
<Körper>
<?php
$num1 = $_GET["num1"];
$num2 = $_GET["num2"];
if($_GET["ysf"]=="+")
$sun = $num1+$num2;
if($_GET["ysf"]=="-")
$sun = $num1-$num2;
if($_GET["ysf"]== "*")
$sun = $num1*$num2;
if($_GET["ysf"]=="/")
$sun = $num1/$num2;
?>
<form action="" method="get">
<input type="text" name="num1"></input>
<select name="ysf">
<option value="+">+</option>
<option value="-">-</option>
<option value="*">*</ option>
<option value="/">/</option>
</select>
<input type="text" name="num2"></input>
<input type="submit" value="计算" name="sub" />
</form>
<?php
if(isset($_GET["sub"] ))
echo $sun;
?>
</body>
</html>