Learning To Do Math In Php!

Discussion in 'GR Classic Archive' started by Joker22x, Oct 27, 2004.

  1. Joker22x

    Joker22x Well-Known Member

    Posts:
    257
    Likes Received:
    0
    Joined:
    Jul 9, 2004
    Ok, first of we need to learn how to set numeric variables, you do this like this:

    Code:
    <?php
    $number1=1
    This sets the 1st variable to 1, now we must select a second variable and a variable for the answer. we do this like so:

    Code:
    <?php
    $number1=1
    $number2=1
    $answer=$number1+$number2
    That will set all the variable that we need, now we must make it show it on the web page, we do this with the echo funtion, the final code looks like this:


    Code:
    <?php
    $number1=1
    $number2=1
    $answer=$number1+$number2
    echo $answer
    ?>

    I hope you learned some good stuff, and enjoyed the tutorial!

    Peace Out,

    Joker
     
  2. Joker22x

    Joker22x Well-Known Member

    Posts:
    257
    Likes Received:
    0
    Joined:
    Jul 9, 2004
    anyone like this tut?
     
  3. DeMiZe

    DeMiZe Well-Known Member

    Posts:
    582
    Likes Received:
    0
    Joined:
    Oct 10, 2004
    yes, but i've grown weary of arithmetic due to prolonged exposure in school :)
     
  4. Gez

    Gez Well-Known Member

    Age:
    37
    Posts:
    1,696
    Likes Received:
    0
    Joined:
    Jul 20, 2004
    Location:
    Wales/UK
    ya i like it but it's just well eh...so easy

    thats extremly basic php

    easy you assign a value to each of the variables, make a varible of ading the other 2 varibles then echo (display) the result, im sure any1 could who has done basic match in there life could work it out, no offence to you in anyway =P
     
  5. diluvium

    diluvium Active Member

    Age:
    37
    Posts:
    32
    Likes Received:
    0
    Joined:
    Oct 22, 2004
    Location:
    Wipperfürth (germany)
    Don't you forgot all the ";"-s at the end of each line?
    Otherwise it's a veeeery simple Tutorial ;)
    It would be nice if you could explain the difference between assignment and comparison-operators (hope the grammar is correct ;) ) or something else..
     
  6. (terror)

    (terror) dark

    Age:
    118
    Posts:
    1,828
    Likes Received:
    0
    Joined:
    Jul 14, 2004
    Location:
    Zaçmaz, Azerbaijan
    Guys it was MEANT to be a very basic tutorial.

    GJ Jok
     

Share This Page