![]() |
Seems advanced to me :)
Hey all,
Ok.. this is my first ever system i'm building using classes and functions. So far i'd say im doing very bloody good with it. Anyhow, I have a question for you more advanced programmers here. I have a class called, dbclass lets say. And in that class, I have a function to check if the username exists, a function to grab the persons name, and some other functions. Then further down, I have a new class, called admin. Obviously extending dbclass. Now, I have a function on here, called welcome. Pretty simple right? Well, my problem is that i've set $email as a session. And the getname function will grab all the users information where the email is the same as the session email. So i'm able to get the name of the user no problem. And all this jargon i'm going on about does infact work. But!, in my welcome function, if I do this... echo "<h3>Welcome back, <span>" . $this->getUsersName($email) . "</span></h3>"; The users name will go above the welcome back text.. like this, adam Welcome back, Do you need to see some code to see what i mean or is this a straight forward fix? Thanks in advance. |
It's a straight forward fix. You're using an echo statement inside of getUsersName(), correct? Instead of echoing the data, put it in a variable, and return it at the end of the function. Then it will work properly, and will allow you to do any of the following:
PHP Code:
|
Thanks for that, I will try this out tomorrow.
|
hmm, I still have the same problem.
This is my getUsersName function.. PHP Code:
PHP Code:
|
It's the echo. When you try and use string concatenation on a function that echo's a value, instead of returning it, the value will appear before the string in which it's been included.
Try this: PHP Code:
|
Dude, your a lifesaver! :D Thanks alot for the help, I understand it now.
|
| All times are GMT. The time now is 01:05 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0