# php arithmetic operators

**PHP arithmetic operator**are used to integer (numeric) value to perform basic operation like

**sum, multiplication, subtraction and division.**

## PHP Supports all basic arithmetic operators :

- Add +
- Subtract –
- Multiply *
- Division /
- Modulus %

lets understand use of arithmetic operator with an example in php.

we already know what is variable and how to assign value in to variable.

## ADD (+) arithmetic operator

First we take an example of addition of two numeric value in php.

here, we have declare two variable with integer value.

<?php

$first = 5;

$second = 2;

$sum = $first + $second;

echo “sum = ” . $sum;?>

The output of example:

sum = 7

In above php addition example we have two variable $first and $second with numeric value 5 and 2 respectively.

The $sum variable store the addition output of two variable $first and $second and then print answer of addition.

## Subtraction (-) arithmetic operator

Now, subtraction of two numeric value, just change the arithmetic operation **minus (-) sign** instead of plus (+) sign in above php example.

<?php

$first = 5;

$second = 2;

$sub = $first – $second;

echo “subtraction = ” . $sub;?>

The output is:

subtraction = 3;

We can make all arithmetic operation such as multiplication, division just change the operator sign in above example.

## Multiplication (*) php example

<?php

$first = 5;

$second = 2;

$mul = $first * $second;

echo “mul = ” . $mul;?>

The output is:

mul = 10;

## Division (/) operator php example

<?php

$first = 10;

$second = 2;

$div = $first / $second;

echo “div = ” . $div;?>

The output is:

div = 5;

## Leave a Reply