Mathematical Operations in PHP
PHP supports mathematical operations as other languages do. It support addition, subtraction, division, multiplication, increment, decrement etc.
Example 1:
<?php
$a=25; $b=5; $c=$a+$b; echo "<br/> Addition of $a and $b is=$c"; $c=$a-$b; echo "<br/> Subtraction of $a and $b is=$c"; $c=$a*$b; echo "<br/> Multiplication of $a and $b is=$c"; $c=$a/$b; echo "<br/> Division of $a and $b is=$c"; echo "<br/> Before Increment value of \$a is=$a"; $a++; echo "<br/> After Increment value of \$a is=$a"; echo "<br/> Before Decrement value of \$b is=$b"; $b--; echo "<br/> After Decrement value of \$b is=$b";
?>
Output:
Addition of 25 and 5 is=30 Subtraction of 25 and 5 is=20 Multiplication of 25 and 5 is=125 Division of 25 and 5 is=5 Before Increment value of $a is=25 After Increment value of $a is=26 Before Decrement value of $b is=5 After Decrement value of $b is=4