Saturday 5 April 2014

Calculator In PHP

Calculator in php Script
Calculator In Php

Php Code For making calculator In Php Which will perform functions such as addition,subtraction,Multiplication,Division.






Code For Calculator In Php


<?php

//The following is the calculator code:



ini_set('display_errors',0); //ini_set for error reporting

if( isset( $_REQUEST['calculate'] ))//isset check whether value is null or not.

{

$operator=$_REQUEST['operator'];

if($operator=="+")// add operator

{

$add1 = $_REQUEST['fvalue']; // getting values of html form

$add2 = $_REQUEST['lvalue']; // getting values of html form

$res= $add1+$add2;//adding values

}

if($operator=="-")//substracting operator

{

$add1 = $_REQUEST['fvalue'];// getting values of html form

$add2 = $_REQUEST['lvalue'];// getting values of html form

$res= $add1-$add2;//substracting values

}

if($operator=="*")//multipilcation operator

{

$add1 = $_REQUEST['fvalue'];//  getting values of html form

$add2 = $_REQUEST['lvalue'];//  getting values of html form

$res =$add1*$add2;//multiply values

}

if($operator=="/")//divide opeartor

{

$add1 = $_REQUEST['fvalue']; // getting values of html form

$add2 = $_REQUEST['lvalue']; //  getting values of html form

$res= $add1/$add2;divide values

}



}

?>

<form> // html form

Enter First Number<input name="fvalue" type="text">

            Select Operator <select name="operator">

<option>+</option>

<option>-</option>

<option>*</option>

<option>/</option>

</select>

Enter Second Number<input name="lvalue" type="text"/>

<input type="submit" name="calculate" value="Calculate" />

                Output =

               <?php echo $res;?>// output results

 </form>


Output Screenshot1

Calculator In Php
Screenshot1
In this example i had made calculator to calculate two values for addition, subtraction, Multiplication, Division.

Refer Articles :-
Articles For Detail Study Programming In Php. Details About Php Code Which I used to make Calculator In php. 


No comments:

Post a Comment

Thanks For Comment Will get you Soon..

About Me

Welcome to Extra Tutorials! My name is Mohammed and I am the 22 year writer, website developer, and photographer behind the blog. Thanks for visiting! Tutorials Jackpot… In addition to Developer, I love to develop websites and I love to write. Starting a php Blog was inevitable for me. What began as a simple way to share all of my Tutorials with friends and family has developed into my Part time job.

Mohammed Padela

WHAT IS PHP PROGRAMMING

WHAT IS PHP PROGRAMMING
WHAT IS PHP PROGRAMMING

Follow Us

Popular Posts

Designed ByBlogger Templates