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 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. Link to comment https://forums.phpfreaks.com/topic/214929-function-small-problem/#findComment-1118051 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.