Sinisterly
Tutorial [PHP] Tutorial Two Numbers - Printable Version

+- Sinisterly (https://sinister.li)
+-- Forum: Coding (https://sinister.li/Forum-Coding)
+--- Forum: PHP (https://sinister.li/Forum-PHP)
+--- Thread: Tutorial [PHP] Tutorial Two Numbers (/Thread-Tutorial-PHP-Tutorial-Two-Numbers)



[PHP] Tutorial Two Numbers - KyleFYI - 02-21-2013

So, using numbers in php is very easy. Remember though coding always starts from 0 not one.

So to add lets say 1 + 1 you'd do it like this.

PHP Code:
<?PHP $number1 = 1; $number2 = 1; $number3 = $number1 + $number2; echo $number3; ?>

This would just echo out "2" that's all.

Lets say if you'd like to multiple 5 by 5 you'd do it like this.

PHP Code:
<?PHP $number1 = 5; $number2 = 5; $number3 = $number1 * $number2; echo $number3; ?>

See I am using * to multiple it, and not a x. But all this will echo out is "25".

There are a lot more witch you should be able to work out on your own.

Note: If you need any help and I have not yet made a tutorial for it please visit php.net.


RE: [PHP] Tutorial Two Numbers - amus3d - 02-27-2013

You should mention that you are using 'operators', not just 'adding' or 'multiplying' numbers.


RE: [PHP] Tutorial Two Numbers - KyleFYI - 03-07-2013

(03-05-2013, 10:51 PM)Monksy Wrote: Wouldn't it be better to teach using functions? It's so much easier than having to edit $number1 + $number2 every time, plus you can use the "add()" function I created below as many times in the code as you want.

Code:
<?php function add($n1,$n2) { echo $n1 + $n2; } add(4,6); ?>

If you look at my other tutorials you'll see I have done on on functions.


RE: [PHP] Tutorial Two Numbers - SQLi - 06-20-2013

Instead of using functions or so, if you only want to add by one, just write the variables name followed by ++. Also, you should put all your tutorials in one thread instead of making a bunch of them.


RE: [PHP] Tutorial Two Numbers - i0xIllusi0n - 06-20-2013

(06-20-2013, 08:27 PM)SQLi Wrote: Instead of using functions or so, if you only want to add by one, just write the variables name followed by ++. Also, you should put all your tutorials in one thread instead of making a bunch of them.

This isn't adding by one though.
But yes, $int++; works perfectly.


RE: [PHP] Tutorial Two Numbers - SQLi - 06-20-2013

(06-20-2013, 09:21 PM)i0xIllusi0n Wrote: This isn't adding by one though.
But yes, $int++; works perfectly.

It isn't? Oh well.


RE: [PHP] Tutorial Two Numbers - i0xIllusi0n - 06-20-2013

(06-20-2013, 10:45 PM)SQLi Wrote: It isn't? Oh well.

It's not, because the other half of the thread is 5+5. And I'm pretty sure he wouldv'e said $number1++; if he wanted to show more about specifically adding 1, rather than any number in general.