Jump to content

function small problem


robert_gsfame

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.