Open
Description
Description
function my_cb($b) { ob_start(); var_dump($b); $r = ob_get_clean(); return $b . $r; } ob_start('my_cb'); echo "hello";
Will result in:
Fatal error: ob_start(): Cannot use output buffering in output buffering display handlers
When using:
function my_cb($b) { $r = print_r($b, true); return $b . $r; }
it works without error (now, this wasn't the case in earlier PHP versions where it had the same issue as can be seen
in the old docs php/doc-en@e8f4c44#diff-a18323268abbc44bce515215167dfae5d0fb378c63ea36bea0f6e537a6a0114aL115)
What's the reason why print_r with return (which uses buffering internally) can be called in an ob callback now, but ob_start still can't?
Anyway though - given this, var_dump
should have a 2nd argument $return to allow returning, so it can be used in ob_start callbacks, where ob_start cannot be used to get it's value