Register for your free account! | Forgot your password?

Go Back   elitepvpers > Blogs > manulaiko3.0
You last visited: Today at 17:19

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Rate this Entry

Programming in PHP - Math Operators

Posted 01/30/2015 at 16:02 by manulaiko3.0

Copy and paste from my website:

Here we are, maths, one of the things that I most hate, but why this tutorial is about math?
In programming 70% is math (the rest are syntax errors), so, if you want to code, you’ll fell in love with maths, or you will improve your logic as much as possible to don’t use maths
What are operators?
Remember when I was 7, in math class the teacher said “Maths are really important” and I think that’s one of the things that I’ve most used in my life. Well, that’s the only thing I learnt in school… maybe I learnt to read/write in school too… and to speak properly… and maybe something more, but what I want to say is that maths are really important, you get the idea right?
So, back on topic, operators are those easy maths things that you know since you were 7:
+

*
/
Yeah, there’s nothing else (or maybe yes…), let’s see how operators works.
Plus

The plus operator, it bassically takes to integers and returns the result… easy right?
<?php $int1 = 123; $int2 = 321; $plus = $int1 + $int2; //That's the same as 123 + 321 = 444 (3 fours, 3! Illuminati confirmed!!!) ?> So, nothing else, the same with the rest of the operators.
Minus

Moar code!!
<?php $int1 = 333; $int2 = 111; $minus = $int1 - $int2; //333 - 111 = 222 ?> Multiplicator

<?php $int1 = 123; $int2 = 413; $multiplication = $int1 * $int2; //123 * 413 (I'm not going to do the maths -.-) ?< Division

<?php $int1 = 214; $int2 = 412; $division = $int1 / $int2; //214 / 412 ?> Module

Well, you might not know this operator, so I’ll explain what it does:
Consider having a division:
11 / 2
This will return 5 (if we don’t care about decimals), but that’s not the correct result.
To check it just do:
5 * 2 = 10
It returns 10, but 10 != 11!!!
Basically, the module operator returns the rest of a division.
11 % 2 = 1
Why?
Because…
11 / 2 = 5
5 * 2 = 10
10 – 11 = 1!!! ILLUMINATI CONFIRMED!!!
Let’s see some code…
<?php $int1 = 32; $int2 = 3; $module = $int1 % $int2; //2 /* * Same as this: * * 32 / 3 = 10 * 10 * 3 = 30 * 32 - 30 = 2 * 2!!! */ So, it’s done, nothing else about operators untill next chapter: Logical Operators.
See you!!
Posted in Uncategorized
Views 325 Comments 0 Email Blog Entry
« Prev     Main     Next »
Total Comments 0

Comments

 

All times are GMT +1. The time now is 17:19.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.