no, the only way I can think of is to βcatchβ the echo instructions to use output buffering, as you already did. I use a very similar function in my code:
function return_echo($func) {
ob_start();
$func;
return ob_get_clean();
}
it is only 2 lines shorter and does the same.
source
share