I have a function which echos the result.
So when i write
get_title() the result gets echoed
How do I capture the result the function echoes into a variable?
I have a function which echos the result.
So when i write
get_title() the result gets echoed
How do I capture the result the function echoes into a variable?
$result = get_title(); should do it. If not then there must be something within the function echoing data and not just returning it.
Why can't you just pass the variable from inside the function?
Im writing a plugin, the function unfortunately echo's out its result.
While it would probably be more efficient to edit the function not to echo (or add a boolean argument to it to indicate whether or not it should echo), you could get around it by using output buffering:
ob_start();
get_title();
ob_end_clean();