【发布时间】:2011-09-28 21:27:21
【问题描述】:
在下面的代码中执行“echo ...”的那 2 行中出现无法解释的“标头已在 #...行发送”错误。
案例的简化版:
<?php
ob_start();
//Initializing FirePHP...
include_once(F_FS_PATH."lib/FirePHPCore/fb.php");
// <--- I've also tried to move the ob_start(), after the FirePHP init,
// <--- instead before it. But it made no difference.
?>
<html>
<div>A lots of HTML (and php) code goes here... Actually my entire page.
FirePHP is also used here many times by multiple invocations
of the function fb('debug text');</div>
</html>
<?php
$all_page_content=ob_get_clean();
if ($GLOBALS["marketing_enabled"])
echo marketingReplaceContent($all_page_content);
else
echo $all_page_content;
ob_flush(); flush();
//Do some other non-printing - but slow stuff.
do_the_silent_slow_stuff_Now();
// <--- presumably the php execution ends here.
?>
我不明白为什么在我打印缓冲区并刷新它之后,FirePHP 会在页面完成时尝试做某事?或者它在尝试什么?我该如何应对这个问题? :(
【问题讨论】:
-
你在
do_the_silent_slow_stuff_Now()做什么?如果有任何触发 php 的调用,它将尝试发送标头,但这是行不通的,因为您已经使用flush()发送了输出。 -
呵呵 :) 是的。我在 do_the_silent_slow_stuff_Now() 中有一个 fb() 调用。我怎么没想到问题就在那里。很简单!我原以为问题会出现在 echo 语句之前的某个地方,但是看那里是不合逻辑的。无论如何,写这个作为对我问题的回复,我会将其标记为答案。对于像我这样困惑的谷歌用户来说,这可能很有用:)
标签: php debugging firebug output-buffering firephp