Jump to content

passing variables between two functions


xfezz

Recommended Posts

function one($y,$z) {
[b]xyz[/b] = some query from the database;
some other calculations using variables $y and $z;
}

function two($yy,$zz) {
some other calculations using variables $yy and $zz;
newVar = [b]xyz[/b]+ 4;
}

I need to use variable xyz to do a calculation in function two. how do I pass one variable to another function? or would I have to run the same query again in function two?
Link to comment
Share on other sites

[code][code]
<?

function Add($x, $y) {
$result = $x + $y;
return $result;
}

function Subtract($returnedRESULT) {
echo $returnedRESULT;
}


$returnedRESULT = Add(2, 3);

Subtract($returnedRESULT);

?>
[/code]
I don't know if more than one value can be passed. maybe if you put them in an array? [/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.