lilywong Posted August 3, 2006 Share Posted August 3, 2006 <table><? echo getName(); ?><table><?function getName(){ $a = "test"; return $a;}?>when i echo the function, i should get test, right ? anything wrong there as when i echo i see nothing. thanks. Quote Link to comment https://forums.phpfreaks.com/topic/16418-function-question/ Share on other sites More sharing options...
extrovertive Posted August 3, 2006 Share Posted August 3, 2006 works fine for me.Might want to change your <? declaration to <?php Quote Link to comment https://forums.phpfreaks.com/topic/16418-function-question/#findComment-68365 Share on other sites More sharing options...
wildteen88 Posted August 3, 2006 Share Posted August 3, 2006 You'll want to define the function first before you use it. So you'll want to this:[code=php:0]<?phpfunction getName(){ $a = "test"; return $a;}?><table><?php echo getName(); ?><table>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/16418-function-question/#findComment-68458 Share on other sites More sharing options...
onlyican Posted August 3, 2006 Share Posted August 3, 2006 What I tend to do is have all functions at the top of the page, just below <body>common used functions go into an includeA couple of scripts I builtAll the code is at the topAll echo's are below (Does not work very well when using Ifs to determin the next move Quote Link to comment https://forums.phpfreaks.com/topic/16418-function-question/#findComment-68463 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.