Hey everybody I want to let you know that I have undertaken the grueling task of getting the heck away from WordPress. I was so sick of the problems and updates I had to do all the time. I am now using my ezbloo system and I am integrating all my old posts into the new system. It sucks, but in the end, I will save bundles of time. I needed to keep things simple and that is why I created ezbloo. I'll have more on this later for you guys after I am done with the total integration of my old posts here. So if you are looking for a post and need it faster, shoot me an email and I will make it a priority. [email protected]

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 /*THIS IS SIMPLE ADDITION*/ $x = 2; $y = 3; echo $x + $y; ?>

Subtracting Numbers Php 7 Operator

This is how we "subtract" numbers using the "Php 7 Operator", now try this.
<?php /*THIS IS SIMPLE SUBTRACTION*/ $x = 9; $y = 5; echo $x - $y; ?>

Multiply Numbers Php7 Operator

This is how we "multiply" numbers using the "Php 7 Operator", so check this out.
<?php /*THIS IS SIMPLE MULTIPLICATION*/ $x = 3; $y = 5; echo $x * $y; ?>

Divide Numbers Php 7 Operator

This is how we "divide" numbers using the "Php 7 operator", now try this example.
<?php /*THIS IS SIMPLE DIVISION*/ $x = 8; $y = 4; echo $x / $y; ?>

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 /*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 ?>

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 /*IN THIS EXAMPLE WE ARE USING EXPONENTS 5 TO THE 3RD POWER THAT WOULD EQUAL 125*/ $x = 5; $y = 3; echo $x ** $y; ?>

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.

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