Ob_start does not call back

I have problems with ob_start. I'm not sure what the deal was made, but I brought it to the simplest possible test ... all the same to no avail. I would expect this code to output "bar" to stdout, but I get nothing and no errors in the error log.

<?php function gzhandler_ex($buffer, $mode) { echo 'bar'; } ob_start('gzhandler_ex'); echo 'foo'; ob_flush(); 

I have never seen this before, but usually I do not use such callbacks.

+7
source share
1 answer

Your handler function should return content you want to output, not the echo.

 function gzhandler_ex($buffer, $mode) { return 'bar'; } 

In addition, ob_flush() not required when called at the end of the script; he is implicit.

+9
source

All Articles