Click to See Complete Forum and Search --> : Function in a String


Anon
08-01-2002, 09:45 PM
I want to put a function in a string:

say I defined function mirror_display()

how would I put that into a string with the output of the function?


$hello = "mirror_display()";

lets say mirror_display() gets data from a mysql database and prints out several rows of <tr><td></td></tr>.

Anon
08-03-2002, 08:09 PM
First you would construct your string in your mirror_display() function something like..


function mirror_display() {
$string = "Line one.\n";
$string .= "Line two.";

// Then return the string to the calling
// function.
return $string;
}

$hello = mirror_display();

echo $hello would then produce.

Line one.
Line two.