如题,源码如下
<!DOCTYPE html>
<html>
<head>
简易计算器
</head>
<본문>
<?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>
<name="ysf" 선택>
<옵션 값="+">+</option>
<옵션 값="-">-</option>
<옵션 값="*">*</ option>
<옵션 값="/">/</option>
</select>
<input type="text" name="num2"></input>
<input type="submit" value="计算" name="sub" />
</form>
<?php
if(isset($_GET["sub"] ))
echo $sun;
?>
</body>
</html>
PHP中文网2018-04-26 14:33:15
코드를 읽은 후 문제가 없습니다. 최종 출력은
<?php if(isset($_GET["sub"])) echo $sun; ?>