Use php to implement addition, subtraction, multiplication and division calculator. The code is very simple!
Copy code The code is as follows:
header("content-type:text/html; charset=utf-8");
session_start();
?>
Simple Computer
$num1=$_POST['num1'];
$num2=$_POST['num2'];
$oper=$_POST['oper'];
$rs=0;
switch($oper){
case "+":
$rs=$num1+$num2;
break;
case "-":
$rs=$num1-$num2;
break;
case "*":
$rs=$num1*$num2;
break;
case "/":
$rs=$num1/$num2;
break;
default: echo "Your input is incorrect";
}
$_SESSION['rs']=$rs;
echo 'The calculation result is:'.$_SESSION['rs'];
?>
http://www.bkjia.com/PHPjc/676921.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/676921.htmlTechArticleUse PHP to implement addition, subtraction, multiplication and division calculator. The code is very simple! Copy the code as follows: ?php header("content-type:text/html;charset=utf-8"); session_start(); ? !DOCTYPE html PUBLIC "-/...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn