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 2 of 2

Thread: PHP Arithmetic

  1. #1
    New to the CF scene
    Join Date
    Nov 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PHP Arithmetic

    When I use:
    PHP Code:
    $grandtotal = ($_SESSION['value'] + $_SESSION['cost'] * 100); 
    or
    PHP Code:
    $grandtotal $_SESSION['value'] + $_SESSION['cost'] * 100
    I get 122.50

    Why doesn't it give me 12250?

  • #2
    Regular Coder
    Join Date
    Jul 2010
    Location
    Oregon City
    Posts
    280
    Thanks
    5
    Thanked 50 Times in 49 Posts
    Order of operations.. plus the values contained in your session variables might be wrong.

    $grandtotal = ($_SESSION['value'] + $_SESSION['cost']) * 100;


  •  

    Posting Permissions

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