robert_gsfame Posted October 1, 2010 Share Posted October 1, 2010 I just want to compare this two functions <?php function myfunction($x) { if($_GET['x']==$x) { return "SELECTED"; } } echo "<option value='test'".myfunction('test').">TEST</option>"; ?> ======================================================= <?php function myfunction($x) { if($_GET['x']==$x) { echo "SELECTED"; } } ?> <option value="test" <?php myfunction("test");?>>TEST</option> * Assume that $_GET['x']=="test" My question: I try to use echo for the first case and option didnt SELECTED until i use return Same thing with the second one, where i have to use return instead of echo can anyone simply explain this thx Quote Link to comment https://forums.phpfreaks.com/topic/214929-function-small-problem/ Share on other sites More sharing options...
BlueSkyIS Posted October 1, 2010 Share Posted October 1, 2010 return means to return the value from the function. echo means to print the value to screen. Quote Link to comment https://forums.phpfreaks.com/topic/214929-function-small-problem/#findComment-1118051 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.