How To Create simple Online Calculator in PHP

How To Create simple Online Calculator in PHP

For creating a simple calculator or currency converter, you don’t need to store anything inside a database, because there are arithmetic operators available in PHP
by default i.e +,-,*, / etc. So you can use these operators to calculate the values in the browser without going to the database.
Now let’s begin.
How to create a calculator using PHP?

**Checkout SEO tips and tricks for 2018

Open notepad and create a new file called “calculator.php” Save it and give the name & extension as mentioned above Now paste below code into that file
you just created.

Simple PHP Calculator


[php] <?php if(isset($_POST[‘submit’])){$value1 = $_ POST[‘value1’]; $value2 = $_POST[‘value2’]; $action = $_POST[‘action’]; if($action==”+”){ echo “Your Answer is: ”; echo $value1+$value2; } if($action==”-“){ echo “Your Answer is: ”; echo $value1-$value2; } if($action==”*”){ echo “Your Answer is: ”; echo $value1*$value2; } if($action==”/”){ echo “Your Answer is: ”; echo $value1/$value2; } } ?>[/php]