Logo Luan Morina
   Arithmetic operators

20
Arithmetic operators
Operator Description
+ Adds two operands
- Subtracts second operand from the first
* Multiply both operands
/ Divide numerator by de-numerator
% Modulus Operator and remainder of after an integer division
++ Increment operator, increases integer value by one
-- Decrement operator, decreases integer value by one
Demo Source Code
<?php
$inputFirst = $_POST["inputFirst"];
$inputSecond = $_POST["inputSecond"];
$operatorOption = $_POST["operatorOption"];
//
$percentage = $inputFirst;
$totalPercentage = $inputSecond;

if ($operatorOption == "+" ) {$aoOutput = $inputFirst + $inputSecond;}
else if ($operatorOption == "-") {$aoOutput = $inputFirst - $inputSecond;}
else if ($operatorOption == "*") {$aoOutput = $inputFirst * $inputSecond;}
else if ($operatorOption == "/") {$aoOutput = round($inputFirst/$inputSecond, 2);}
else if ($operatorOption == "%") {$aoOutput = ($percentage / 100) * $totalPercentage;}
else if ($operatorOption == "++") {$aoOutput = $inputFirst + $inputSecond +1;}
else if ($operatorOption == "--") {$aoOutput = $inputFirst + $inputSecond -1;}

echo $aoOutput;
?>
   PHP Arithmetic Operators