Home Tutorial Php Phpbasics Tutorial PHP Mathematical Operation

 
 

PHP Mathematical Operation
Posted on: November 3, 2009 at 12:00 AM
Advertisement
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

 

Advertisement

Related Tags for PHP Mathematical Operation:


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.

Posted on: November 3, 2009

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com