SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast AimyThomas's Avatar
    Join Date
    Sep 2011
    Posts
    46
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Need little help in Coding

    I have been starting

    What wrong with this? ive been staring at it but not coming up with anything

    im getting syntax error, unexpected T_RETURN where it says " return $result; "

    <?php



    function add_subtract ($value1, $value2) {
    $add = $value1 + $value2;
    $subtract = $value1 - $value2;
    $result = array($add, $subtract)
    return $result;
    }

    $resultArray = add_subtract (10,5);
    echo "Add: ".$resultArray[0];
    echo "Subract: " .$resultArray[1];

    ?>


    Thanks in advance

  2. #2
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    4,810
    Mentioned
    141 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AimyThomas View Post
    syntax error, unexpected T_RETURN
    Here was your first clue. When you see "syntax error", that is EXACTLY what it means. You are not following the PHP syntax. Look for missing semi-colons, parenthesizes, too many parenthesizes, etc.
    Be sure to congratulate xMog on earning April's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2011
    Location
    Novi Sad
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You are missing semicolon on end of line:

    PHP Code:
    $result = array($add$subtract); 


Bookmarks

Posting Permissions

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