开发者

ob_start not executing callback

开发者 https://www.devze.com 2023-03-06 05:21 出处:网络
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\' t

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

精彩评论

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