Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: Php + -

  1. #1
    Regular Coder
    Join Date
    Mar 2009
    Posts
    107
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Php + -

    Hi, quick post, im just tryna figure out how to plus and subtract etc using php.

    cant find any tutorials.

    for example heres what i want to do

    Code:
    <?
    
    $MAGICNUMBER = 1+5 ;
    
    ?>
    
    <? echo "$magicnumber" ?>
    just wondering if any body knows of a tutuorial or could show me how that should be set out.

    would be appreciated.

    thanks Allot in advance

    Liam

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,470
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    What you're doing is OK, but the variables must be the same (caps and small letters).
    You have one all caps, the other all small ... which is incorrect.

    To increment the variable, both of these produce the same result:

    $magicnumber = $magicnumber + 1;
    $magicnumber++;

    Pay attention to case-sensitivity ... your variables.

    EDIT:
    Not all webhosts are set-up the same for PHP, in regards to <?

    You may be able to do this ...
    <?
    // code
    ?>

    or you may have to do this ...
    <?php
    // code
    ?>
    Last edited by mlseim; 10-16-2009 at 04:38 PM.

  • #3
    Regular Coder
    Join Date
    Mar 2009
    Posts
    107
    Thanks
    15
    Thanked 0 Times in 0 Posts
    THANKS ALLOT

    i know that php is usually case sensitive, i just missed the fact id wrote one in caps and one without, i must have had caps on for some other reason.

    i knew that could be done, and assume that's how i should do it, but when it didnt work i just assumed id done it wrong and couldnt find a tutorial

    again, thanks for your help

    Liam

  • #4
    met
    met is offline
    Regular Coder
    Join Date
    Oct 2009
    Location
    United Kingdom
    Posts
    728
    Thanks
    4
    Thanked 119 Times in 119 Posts
    this is great to start off http://www.tizag.com/phpT/


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •