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

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’];
?>

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/simple-implementation-of-addition-subtraction-multiplication-and-division-calculator-using-php_php/

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

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
首页
微信
电话
搜索