Implement the subtraction calculator in PHP. The code is very simple Oh!
Copy Code code as follows:
<?php
Header ("Content-type:text/html;charset=utf-8");
Session_Start ();
?>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title> Simple Computer </title>
<body>
<form action= "jisuan.php" method= "POST" >
The first number <input type= "text" value= "" Name= "Num1" ><br/>
Computational symbols <select name= "oper" >
<option value= "+" >+</option>
<option value= "-" >-</option>
<option value= "*" >*</option>
<option value= "/" >/</option>
</select><br/>
The second number <input type= "text" value= "" Name= "num2" ><br/>
<input type= "submit" value= "Calculated results" ><br/>
</form>
</body>
<?php
$num 1=$_post[' NUM1 '];
$num 2=$_post[' num2 '];
$oper =$_post[' oper '];
$rs = 0;
Switch ($oper) {
Case "+":
$rs = $num 1+ $num 2;
Break
Case "-":
$rs = $num 1-$num 2;
Break
Case "*":
$rs = $num 1* $num 2;
Break
Case "/":
$rs = $num 1/$num 2;
Break
Default:echo "You have entered incorrectly";
}
$_session[' rs ']= $rs;
Echo ' Computes the result as: '. $_session[' rs '];
?>