### PHP Arithmetic operator

The arithmetic operators handle basic numerical operations, such as addition and multiplication.

Operator Name Description
+ Addition Sum of \$a and \$b.
- Subtraction Difference of \$a and \$b.
* Multiplication Product of \$a and \$b
/ Division Quotient of \$a and \$b
% Modulus Remainder of \$a divided by \$b.
** Exponentiation Result of raising \$a to the \$b'th power. Introduced in PHP 5.6.
+= Shorthand addition Equivalent to \$a = \$a + \$b.
-= Shorthand subtraction Equivalent to \$a = \$a - \$b
*= Shorthand multiplication Equivalent to \$a = \$a * \$b.
/= Shorthand division Equivalent to \$a = \$a / \$b.

The division operator ("/") returns a float value unless the two operands are integers (or strings that get converted to integers) and the numbers are evenly divisible, in which case an integer value will be returned.

Operands of modulo are converted to integers (by stripping the decimal part) before processing

The result of the modulo operator % has the same sign as the dividend — that is, the result of \$a % \$b will have the same sign as \$a

### Example

```		  		<?PHP
\$a = 13;
\$b = 4;
\$c = 3.33;
\$d = 3.99999999;
\$e = -10;
\$f = -4;

print \$a + \$b;
print "\n";
print \$a - \$c;
print "\n";
print \$a * \$d;
print "\n";
print \$a / \$f;
print "\n";
print \$e % \$b;
?>
```

### Example

```		  		<?PHP
echo (5 % 3)."\n";
echo (5 % -3)."\n";
echo (-5 % 3)."\n";
echo (-5 % -3)."\n";
?>
```

### Example

```		  		<?PHP
if ((\$a % 2) == 1)
{ echo "\$a is odd." ;}
if ((\$a % 2) == 0)
{ echo "\$a is even." ;}
?>
```

### Example

```		  		<?PHP
for (\$i = 1; \$i <= 10; \$i++) {
if((\$i % 2) == 1)  //odd
{echo "<div class=\"dark\">\$i</div>";}
else   //even
{echo "<div class=\"light\">\$i</div>";}
}
?>
```

### Example

```		  		<?PHP
\$d = dir('./');
\$i = 0;
while(false !== (\$e = \$d->read())){
if(strpos(\$e,'.gif')){
++\$i;
echo '<img src="'.\$e.'"/>'.chr(10);
if(!(\$i%5))
echo '<br/>';
}
}
?>
```

### Example

```		  		<?PHP
\$x = 6;
\$y = 4;

echo \$x + \$y;
?>
```

### Example

```		  		<?PHP
\$x = 15;
\$y = 9;

echo \$x - \$y;
?>
```

### Example

```		  		<?PHP
\$x = 9;
\$y = 5;

echo \$x * \$y;
?>
```

### Example

```		  		<?PHP
\$x = 12;
\$y = 6;

echo \$x / \$y;
?>
```

### Example

```		  		<?PHP
\$x = 10;
\$y = 5;

echo \$x % \$y;
?>
```