MDanz Posted January 10, 2011 Share Posted January 10, 2011 i'm having trouble getting my function to return back variables to the page that called it. in the function i have variables $student1, $student2 $student3 in a function called getstudent. the code below on page student.php calls the function, if i return $student3 on page student.php if i echo $student3 it is blank. any ideas?.. i don't want to echo it within the function. $thedatabase = new Database(); $thedatabase->opendb(); $input = $thedatabase->getstudent($student); return $student3; Quote Link to comment https://forums.phpfreaks.com/topic/223929-function-help/ Share on other sites More sharing options...
trq Posted January 10, 2011 Share Posted January 10, 2011 Your capturing the returned value into $input not $student3. Quote Link to comment https://forums.phpfreaks.com/topic/223929-function-help/#findComment-1157252 Share on other sites More sharing options...
Zurev Posted January 10, 2011 Share Posted January 10, 2011 i'm having trouble getting my function to return back variables to the page that called it. in the function i have variables $student1, $student2 $student3 in a function called getstudent. the code below on page student.php calls the function, if i return $student3 on page student.php if i echo $student3 it is blank. any ideas?.. i don't want to echo it within the function. $thedatabase = new Database(); $thedatabase->opendb(); $input = $thedatabase->getstudent($student); return $student3; It's really difficult trying to interpret it with that little bit of code, no specifics on the function or anything...could you try and specify? EDIT: thorpe didn't seem to have any issues with it. What you're saying is about right, you don't want to ever echo from the function when you can return. However if something returns a value, you need to echo it where ever you are calling it. Quote Link to comment https://forums.phpfreaks.com/topic/223929-function-help/#findComment-1157253 Share on other sites More sharing options...
MDanz Posted January 10, 2011 Author Share Posted January 10, 2011 nvm Quote Link to comment https://forums.phpfreaks.com/topic/223929-function-help/#findComment-1157259 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.