what you could do is edit the function to return a variable instead of printing it.
i usually use something like:
function test()
{
$output = "Hello";
$output .= " This will be";
$output .=" set as the return value";
$output .= " of this function";
return $output;
}
so now,
$var = test();
print $var;
would print ,
Hello This will be set as the return value of this function
to the browser.