Php 7 operators are used for Arithmetic and Calculations. It is also used for comparing values. If we used Php 7 for arithmetic and calculations we would be using add, subtract, multiply, divide, modulus and exponents. Here are files from the last lesson. Here are files for this lesson.

## Php 7 Arithmetic Operators Examples

- + adding numbers
- – subtracting numbers
- / dividing numbers
- * multiply numbers
- % modulus numbers
- ** exponents (
*indices in all other countries except the USA*)

### Adding Numbers Php 7 Operator

This is how we “**add**” numbers using the “**PHP 7 Operator**“.

[php]<?php /*THIS IS SIMPLE ADDITION*/ $x = 2; $y = 3; echo $x + $y; ?>[/php]

### Subtracting Numbers Php 7 Operator

This is how we “**subtract**” numbers using the “**Php 7 Operator**“, now try this.

[php]<?php /*THIS IS SIMPLE SUBTRACTION*/ $x = 9; $y = 5; echo $x – $y; ?>[/php]

### Multiply Numbers Php7 Operator

This is how we “**multiply**” numbers using the “**Php 7 Operator**“, so check this out.

[php]<?php /*THIS IS SIMPLE MULTIPLICATION*/ $x = 3; $y = 5; echo $x * $y; ?>[/php]

### Divide Numbers Php 7 Operator

This is how we “**divide**” numbers using the “**Php 7 operator**“, now try this example.

[php]<?php /*THIS IS SIMPLE DIVISION*/ $x = 8; $y = 4; echo $x / $y; ?>[/php]

### Modulus Php 7 Operator

Modulus is dividing a number, so if you have anything left over that is the “**modulus**“. This is how you do “**modulus”** in the “**Php 7 operator**“.

[php]<?php /*THIS IS MODULUS IF YOU DIVIDE BY 2 NUMBERS AND HAVE ANYTHING LEFT OVER THAT IS YOUR MODULUS.*/ $x = 3; $y = 2; echo $x % $y; //ANSWER IS 1 ?>[/php]

### Exponents Php 7 Operator

To get exponents in Php 7 you will use the double asterix, (**). This is how you do “**exponents**” in the “**Php 7 Operator**“.

[php]<?php /*IN THIS EXAMPLE WE ARE USING EXPONENTS 5 TO THE 3RD POWER THAT WOULD EQUAL 125*/ $x = 5; $y = 3; echo $x ** $y; ?>[/php]

## Conclusion Arithmetic Operators PHP 7

In order to understand a programming language you also need to understand the mathematics of that language. There are other operators that we will cover in the next lesson. I thought it was appropriate to break these lessons down to keep them simple. Next lesson we will use operators to compare two values. We will then show result based upon the comparison. PHP 7 operators are going to be a powerful arsenal in your programming toolbox.

We will be using the knowledge you gain here and apply it to our project PennsylvaniaWilds.org.

Like share and subscribe to these lessons so we can keep them free.

## A1WEBSITEPRO Social Media Pages

Here are my social media pages, lets hook up!