Closed bobbingwide closed 4 years ago
In the current version of the documentation for print_r() https://www.php.net/manual/en/function.print-r.php it says
Note: When the return parameter is used, this function uses internal output buffering so it cannot be used inside an ob_start() callback function.
In the documentation for ob_start() https://www.php.net/manual/en/function.ob-start.php we see this
ob_end_clean(), ob_end_flush(), ob_clean(), ob_flush() and ob_start() may not be called from a callback function. If you call them from callback function, the behavior is undefined. If you would like to delete the contents of a buffer, return "" (a null string) from callback function.
You can't even call functions using the output buffering functions like print_r($expression, true) or highlight_file($filename, true) from a callback function.
The reason I'm writing this is that I'm not sure if I still need to worry about having to call bw_trace_obsafe_print_r()
.
And if I don't have to do that then why do we need to know about output buffer handlers?
I think one of the problems is that I may not be producing the error situation yet.
When output buffering is active we can't use
print_r()
so we callbw_trace_obsafe_print_r()
. See #1.Tracing of large data structures is significantly slower using the replacement function. It would be nice to know what output buffering handlers are active. This may help us determine how to speed up tracing.