halm1985 Posted September 24, 2007 Share Posted September 24, 2007 How can i make variables set in a function available for use in other functions within the page .. Quote Link to comment https://forums.phpfreaks.com/topic/70502-passing-variables-within-functions/ Share on other sites More sharing options...
pocobueno1388 Posted September 24, 2007 Share Posted September 24, 2007 Use the return keyword. Here is an example of how you could get a variable for use outside a function. <?php function createVar($value){ $var = $value; return $var; } Now you could do this: $var = createVar($value); and then you have the variable $var to use outside of the function. Quote Link to comment https://forums.phpfreaks.com/topic/70502-passing-variables-within-functions/#findComment-354155 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.