Jump to content

function help


MDanz

Recommended Posts

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;

Link to comment
https://forums.phpfreaks.com/topic/223929-function-help/
Share on other sites

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. :(  :P

 

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.

Link to comment
https://forums.phpfreaks.com/topic/223929-function-help/#findComment-1157253
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.