SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast vaiod's Avatar
    Join Date
    Jan 2001
    Location
    Chandler, Arizona
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How can I process data in a function, assign a variable then pull that info out when not in the function. EX: I have a function that determines if a given date is in the past or future and I want to be able to assign "PAST" or "FUTURE" to $status. If I call the function in the place where I want to print the variable:

    echo("(CheckExpire ( $mydate ))");

    I get the output PAST if the date is in the past but if I try:

    $status = (CheckExpire ( $mydate ));
    echo("$status");

    I get nothing. What am I overlooking? Please help!!

  2. #2
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Location
    Pittsburgh, PA, USA
    Posts
    3,910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You have to return the value. At the end of the function, you need this...

    Code:
    return $var;
    ...where $var is the name of the value you want to SEND BACK to the script calling the function -- this way you can "capture" it with the $status variable, per your code above.

  3. #3
    SitePoint Enthusiast vaiod's Avatar
    Join Date
    Jan 2001
    Location
    Chandler, Arizona
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Excellent

    Excellent... Thank you MUCH...


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
  •