Arithmetic in PHP
Arithmetic Operator
The arithmetic operator commonly used in PHP script are listed in the table below together with the operator they performed
Operator Operation
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulus
++ Increment
-- Decrement
Operator for addition , subtraction , multiplication , and division act you would expect .
PHP Program
<?php
$a=8;
$b=4;
$result=$a+$b;
echo "Addition : $result";
$result=$a-$b;
echo "Subtraction : $result";
$result=$a*$b;
echo "Multiplication : $result";
$result=$a/$b;
echo "Division : $result";
$result=$a % $b;
echo "Modules : $result";
$a++;
echo "Increment : $a";
$b--;
echo "Decrement : $b";
?>
Comments
Post a Comment