Share on Google+Share on Google+

PHP Mathematical Operation

PHP Mathematical Operation: In this tutorial you will learn about various mathematical operations supported by PHP. Examples will illustrate various mathematical operations

Mathematical Operations in PHP

PHP supports mathematical operations as other languages do. It support addition, subtraction, division, multiplication, increment, decrement etc.

Example 1:





echo "<br/> Addition of $a and $b is=$c";


echo "<br/> Subtraction of $a and $b is=$c";


echo "<br/> Multiplication of $a and $b is=$c";


echo "<br/> Division of $a and $b is=$c";

echo "<br/> Before Increment value of \$a is=$a";


echo "<br/> After Increment value of \$a is=$a";

echo "<br/> Before Decrement value of \$b is=$b";


echo "<br/> After Decrement value of \$b is=$b";



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



Posted on: November 3, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.