How To Create simple Online Calculator in PHP

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 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; } } ?>
Prince Kwekowe
administrator
Entrepreneur, Programmer, Technophile, Tech Instructor and CEO at w3tutor.org. Has a Degree in Artificial Intelligence and Entrepreneurship. He is passionate about Technology, Robotics, Entrepreneurship and SEO. When he's not Programming, writing or teaching, Prince engages in playing video games, cooking or playing the guitar.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.