dongyinshua9996 2015-06-20 00:29
浏览 41
已采纳

ob_start()旁边出现“false”

I appear to have a ghost. I'm loading a page (normally loaded inside another page, if that helps, but the bug still appears when I load the page by itself) and at the top of the output, before everything else, I get a random false.

It is output during $this->load->view('my_view');. I went and investigated the CodeIgniter system files and found, within the _ci_load($_ci_data) method, a line that says ob_start();. When I put lines around this code like this:

echo "hey!";
ob_start();
echo "here!";

the output I get is hey!falsehere!.

The only way I've found that I can stop the false from being output is by putting another ob_start() somewhere before that in the code. I've fiddled with different placements, in the controller, the view, the view loader, and in CodeIgniter.php itself. Here's where I found it breaks:

// Is there a "remap" function? If so, we call it instead
if (method_exists($CI, '_remap'))
{
    $CI->_remap($method, array_slice($URI->rsegments, 2));
}

If I put ob_start() before the call to _remap, the false goes away; if I put it right afterwards, the false still shows up.

Anyone know what to do? I know this is a really hard and obscure question, but I have no idea what the next step I should take is. Any recommendations of where the problem could possibly be coming from are very much welcome.

I'm running PHP 5.4.30, using CodeIgniter 2.1.4 (probably time to update ...)

  • 写回答

1条回答 默认 最新

  • dongqiang2358 2015-07-14 20:34
    关注

    Turns out the problem was deep inside a model called by another model called by the controller that was outputting a false when a certain error condition happened. Moral of the story, search deeper into my own code instead of blaming it on a bug in the framework ...

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?