Results 1 to 4 of 4

Thread: [RESOLVED] Functions

  1. #1

    Thread Starter
    Hyperactive Member OMITT3D's Avatar
    Join Date
    Mar 2006
    Posts
    368

    Resolved [RESOLVED] Functions

    Hi I am new to PHP functions and was wondering why this isn't working.

    PHP Code:
    function curdate($supdate) {
        
    $return_date $supdate{0};
        
    $return_date $return_date.$supdate{1};
        if(
    $return_date == '01') {
            
    $return_date == 'January';
        } 
    //etc etc
        
    reuturn $return_date;

    It's being called with
    PHP Code:
    $supdate curdate($row['signed_up']); 
    $row['signed_up'] Say would be equal to 032588 meaning March 25, 1988. The error is:
    Code:
    Parse error: parse error, unexpected T_VARIABLE in C:\Program Files\xampp\htdocs\rpg\config.php on line 19
    Line 19 = return $return_date;

    Also is there a better way to dow hat I am doing?

  2. #2
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: Functions

    PHP Code:
    //Currently
    reuturn $return_date
    PHP Code:
    //Should be
    return $return_date

  3. #3
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Functions

    I assume $supdate is an array. Square brackets [] are the index operators, not braces {}.

    You've also used the equality operator == on its own in a statement, I assume you meant $return_date = 'January' instead.

    PHP Code:
    function curdate($supdate)
    {
      
    $return_date $supdate[0].$supdate[1];

      if (
    $return_date == '01') {
        
    $return_date 'January';
      }
      
      return 
    $return_date;

    Also, I don't know what you are doing (the function looks to me, for want of a better word, pointless), so I can't suggest a better way.

  4. #4

    Thread Starter
    Hyperactive Member OMITT3D's Avatar
    Join Date
    Mar 2006
    Posts
    368

    Re: Functions

    Yeaaa lol wow. I figured out a better way of doing what I'm trying to do thanks to someone on these forums. Yes I know how to spell return, and yes I know it's $return_date = 'January'; lol I can't believe I caught neither of those mistakes. Anyways thanks for spell checking my code

Posting Permissions

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



Click Here to Expand Forum to Full Width