Simple implementation of addition, subtraction, multiplication and division calculator using PHP_PHP

Use php to implement addition, subtraction, multiplication and division calculator. The code is very simple! The code is as follows: <?php header(“content-type:text/html;charset=utf-8”); session_start(); ?> The first number Calculation symbol + – * / The second number <?php $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’]; ?>

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: 34331943@QQ.com

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索