Monday, April 30, 2012

PHP Basic Math Function Tutorial


Basic Math Function
PHP is pretty much like a big calculator.
You can do basic math function right in your variable. A variable equal to whatever equations you have and then displays the output on the screen. Bunch of stuff you can do, like addition, subtraction, multiply, division, remainder, etc.
Example: 1
        <?php
        $anything = 10;
        echo $anything;
        ?>
Output
10

Addition
Example: 2
        <?php
       $anything = 10+500;
       echo $anything;
        ?>
Output
510

Subtraction
Example: 3
        <?php
       $anything = 10-500;
       echo $anything;
        ?>
Output
-490

Adding two variables
Example: 3
        <?php
       $anything = 55;
       $something = 45;
       echo $anything + $something;
        ?>
Output
100

No comments:

Post a Comment