Output buffering functions sound like something you could use:
<?php
function OtherStuff()
{
echo "MONKEY!!!<br>\n";
}
function DoStuff()
{
echo "Something<br>\n";
echo "Something else<br>\n";
OtherStuff();
}
// Start output buffering.
ob_start();
// Grab the content.
DoStuff();
$content = ob_get_contents();
// Finish up.
ob_end_clean();
// What to do with $content?
echo "Content is: <b>" . $content . "</b>\n";
?>
However, this could get messy and might not be what you're really after. If
you're just wanting to return values from your functions, use return:
function OtherStuff()
{
return "Monkey!<br>\n";
}
function DoStuff()
{
$output = "Something<br>\n";
$output .= "Something else<br>\n";
$output .= OtherStuff();
return $output;
}
$content = DoStuff();
echo "Content = " . $content;
would have a similar effect to the output method above.
Anyway, further reference for you on output buffering can be found here:
http://www.php.net/manual/en/ref.outcontrol.php
-James
"Shawn McKenzie" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I have a script with some functions and within the script I want to read
the
> code from one of the functions into a string.
>
> Example:
>
> function myfunction() {
> echo "something";
> echo "something else";
> someotherfunction();
> }
>
> I want to read:
>
> echo "something";
> echo "something else";
> someotherfunction();
>
> into a string.
>
> Any ideas??? TIA
> -Shawn
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php