I have the following code:
function a(){ die( 'some text' ) }
ob_start();
a();
$return = ob_get_clean();
echo 'result:'
var_dump( $return );
and it doesn't work.
I get some text
in my browser.
How can I make it work? How can I catch die()
in a buffered function?
PS: I cannot change the function.
What should I use instead of ob_start() ?
I tried to run the following code:
register_shutdown_function( function() {
$message = ob_get_contents(); //Capture 'Doh'
ob_end_clean(); //Cleans output buffer
} );
ob_start();
die( 'works' );
ob_end_clean();
and it didn't work...