If you are visual learner and prefer video tutorial then here you go.
There is possibility that playing this is at your current location is not approcriate then you can go through the article and you will get the same knowledge.
In this article we are going to learn about creating Simple Calculator using PHP. Simple Calculator means a calculator which is capable of doing simple operation like add, subtract, product (multiply) and division.
Create One folder learn( you can name folder anything ).
Open the folder in your editor and create one new file index.php.
As I told you our calculator is capable of doing only three jobs(tasks).
Addition
Subtraction
Multiplication
Division
We require atleast two number to perform any of these operations. We will crete two input field for getting user input. We will require four different button of four different operations.
We are going to write all the things in one file. We don’t require multiple file to do build this calculator.
<?php$error="";$x="";$y="";$result="";if(isset($_GET['operation'])){$x=$_GET['num1'];$y=$_GET['num2'];$op=$_GET['operation'];if(is_numeric($x)&&is_numeric($y)){switch($op){case'add':$result=$x+$y;break;case'sub':$result=$x-$y;break;case'pro':$result=$x*$y;break;case'div':$result=$x/$y;break;}}else{$error="Enter Number first";}}?>