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