开发者

ob_start not executing callback

I'm having issues with ob_start. Not sure what the deal is, but I've bubbled it down to the simplest possible test case... still to no avail. I wo开发者_如何学Culd expect this code to output 'bar' to the stdout, but I'm getting nothing back, and no errors in my error log.

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

ob_start('gzhandler_ex');
echo 'foo';
ob_flush(); 

I've never seen this before, but I don't typically use callbacks like this.


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

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

Also, the ob_flush() is unnecessary when called at the end of the script; it is implicit.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜