apache在doc下的开启与关闭
//需要配置apache安装环境变量
httpd -k start 开启
httpd -k stop 关闭
httpd -k restart 重启
appserv下载:点击下载
<!DOCTYPE html>
<html>
<head>
<title>
计算器
</title>
</head>
<body>
<div align="center">
<h1>计算器</h1>
<form action="counter.php" method="post">
num1:<input type="text" name="num1">
<select name="oper">
<option value="+">+</option>
<option value="-">-</option>
<option value="*">*</option>
<option value="/">/</option>
</select>
num2:<input type="text" name="num2">
<input type="submit" value="提交">
<br/>
<?php
// require 'counter02.php';
if(isset($_REQUEST['num1']))
{
$num1=$_REQUEST['num1'];
}
else if(isset($_REQUEST['num2']))
{
$num2=$_REQUIEST['num2'];
}
else if(isset($_REQUEST['oper']))
{
$oper=$_REQUEST['oper'];
}
$count=new counter();
?>
<h3>结果:</h3>
<?php
echo $count->getResult($num1,$num2,$oper);
?>
<?php
class counter{
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 $num1/$num2;
break;
default:
echo "请输入数据。";
}
}
}
?>
</div>
</body>
</html>
![](https://img-my.csdn.net/uploads/201210/15/1350298607_9345.png)