Re: PHP newbie ... function with several returns ?
| From: | Tom Rogers | Date: | Sun, 16 Mar 2003 01:16:01 +0000 |
| Subject: | Re: PHP newbie ... function with several returns ? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-139822@lists.php.net to get a copy of this message | ||
Hi,
Sunday, March 16, 2003, 10:52:49 AM, you wrote:
RD> Hi ... PHP newbie here.
RD> I'm migrating from ASP/vbScript.
RD> I'd like to set up a subroutine that will change several variables at once.
RD> In VB, I can say:
RD> Private Sub Change_Variables ($variable1, $variable2)
RD> $variable1 = "Something different from it's original value"
RD> $variable2 = "I'm changed also!!"
RD> End Sub
RD> // in my code I can call it like this:
RD> $My_variable1 = "This is the original value of variable1"
RD> $My_variable2 = "This is the original value of variable2"
RD> Call Change_Variables ($My_variable1, $My_variable2)
RD> // after calling this subroutine the variables are changed:
RD> print $My_variable1 // yeilds: "Something different from it's original
RD> value"
RD> print $My_variable2 // yields: "I'm changed also!!"
RD> I try to convert this to PHP, and I'm getting stuck. I'm sure there's a
RD> kind of function that can do this.
RD> Any ideas?
RD> TIA
You need this:
function Change_Variables (&$variable1, &$variable2){
$variable1 = "Something different from it's original value"
$variable2 = "I'm changed also!!"
}
(notice the '&' symbols)
--
regards,
Tom