dezkit Posted May 28, 2008 Share Posted May 28, 2008 im new to functions and i was wondering, why isnt this working? <?php function name(){ $firstname = "Pamela"; $lastname = "Anderson"; echo "$firstname $lastname"; } echo "The hottest bitch in the world is ".name(); ?> it displays, "Pamela AndersonThe hottest bitch in the world is" Quote Link to comment https://forums.phpfreaks.com/topic/107558-solved-functions-new/ Share on other sites More sharing options...
dezkit Posted May 28, 2008 Author Share Posted May 28, 2008 nevermind, i figured it out, now is there a way to echo (or whatever its called) a function in an echo? like: echo "The hottest bitch in the world is name()"; Quote Link to comment https://forums.phpfreaks.com/topic/107558-solved-functions-new/#findComment-551321 Share on other sites More sharing options...
Prismatic Posted May 28, 2008 Share Posted May 28, 2008 nevermind, i figured it out, now is there a way to echo (or whatever its called) a function in an echo? like: echo "The hottest bitch in the world is name()"; <?php function name(){ $firstname = "Pamela"; $lastname = "Anderson"; return $firstname ." ". $lastname; } echo "The hottest bitch in the world is ". name(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/107558-solved-functions-new/#findComment-551324 Share on other sites More sharing options...
dezkit Posted May 28, 2008 Author Share Posted May 28, 2008 heh, thanks, got it Quote Link to comment https://forums.phpfreaks.com/topic/107558-solved-functions-new/#findComment-551325 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.