Calculator In Php
Php Code For making calculator In Php Which will perform functions such as addition,subtraction,Multiplication,Division.
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>
Screenshot1 |
Refer Articles :-
- ASSIGNMENT OPERATORS IN PHP
- ARITHMETIC OPERATORS IN PHP
- LOGICAL OPERATORS IN PHP
- IF_ELSE IF STATEMENT IN PHP
- VARIABLES IN PHP
- ECHO STATEMENT IN PHP
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..