The Little Guy Posted September 20, 2011 Share Posted September 20, 2011 I am making a function it returns one thing, but I would the like to put something into a variable to use outside the function. for example, the third parameter in preg_match() sets a variable that you can then use later in your code, how can I create a parameter like that? Quote Link to comment https://forums.phpfreaks.com/topic/247481-parameters-outside-the-function/ Share on other sites More sharing options...
xyph Posted September 20, 2011 Share Posted September 20, 2011 Passing by reference http://php.net/manual/en/language.references.pass.php Quote Link to comment https://forums.phpfreaks.com/topic/247481-parameters-outside-the-function/#findComment-1270874 Share on other sites More sharing options...
The Little Guy Posted September 20, 2011 Author Share Posted September 20, 2011 haha, thanks, but I just figured it out! <?php function something(&$var){ $var = "hello"; return true; } something($cat); echo $cat; ?> Quote Link to comment https://forums.phpfreaks.com/topic/247481-parameters-outside-the-function/#findComment-1270875 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.