验证中...
私信发送成功
语言: PHP
分类: 编程语言基础
最后更新于 2018-01-13 20:55
gistfile1.txt
原始数据 复制代码
//类的构建
<?php
class operSever{
public function getResult($num1,$num2,$oper){
switch($oper){
case "+":
return $num1+$num2;
break;
case "-":
return $num1-$num2;
break;
case "*":
return $num1*$num2;
break;
case "/":
return $num/$num2;
break;
default:
echo "请输入正确的计算方法";
}
}
}
?>
//视图层
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
<meta name=description content="">
<meta name=viewport content="width=device-width, initial-scale=1">
<title>视图层</title>
</head>
<body>
<form action="result.php" method="get" accept-charset="utf-8">
<input type="text" name="num1" placeholder="请输入第一个数字"><br><br>
<input type="text" name="num2" placeholder="请输入第二个数字"><br>
<select name="oper" >
<option value="+">+</option>
<option value="-">-</option>
<option value="*">*</option>
<option value="">/</option>
</select>
<br>
<input type="submit" name="" value="提交">
</form>
</body>
</html>
//接收数据
<?php
require_once 'operSever.class.php';
$num1=$_REQUEST["num1"];
$num2=$_REQUEST["num2"];
$oper=$_REQUEST["oper"];
$obj=new operSever();
echo $obj->getResult($num1,$num2,$oper);
?>

评论列表( 0 )

你可以在登录后,对此项目发表评论

6_float_left_people 6_float_left_close