In this tutorial we will see how to create a simple Calculator in PHP. Our calculator will do all basic arithmetic operations like addition,subtraction, division and multiplication. In this process I have used two input box to enter operands for mathematical operations and used one select box to choose operators. Calculate button is used to perform action on given operands according to selected operators. I have displayed results in an input box which have readonly attribute so that user can only see the output of calculation but will not be able to change its value. I have created a class file having methods to perform different arithmetic operations.
HTML
Simple calculator form is create using HTML.
Simple calculator in PHP
PHP
PHP file is created to perform mathematical operations.
getResult($num1, $num2, $operator); } else { echo "Please enter numeric value!!"; } } ?>
I have written this tutorial keeping in mind about beginners who wants to learn how to create simple calculator in PHP. They can easily understand this simple scripts and they will also get concept of OOPs, methods, property, switch and how to use it.
The post Simple Calculator in PHP appeared first on PHPCluster.
This post first appeared on Best PHP Programming Blog, Blog For PHP Developers, PHP Tutorial,PHP Blog For Beginners, please read the originial post: here