# 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

Ads

Tutorials

Share on Google+

# PHP Mathematical Operation

Ads

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:

<?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```

Advertisements

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

Related Tutorials