I get unexplained “Headers already sent on line #…” error on those 2 lines that execute “echo …” in the code below.
Simplified version of the case:
<?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.
?>
I cannot understand why FirePHP is trying to do something upon page completion after I print the buffer and flushed it? Or what is it trying? How can I cope with this problem? 🙁
Here’s your problem:
Thats exaclty what happens when you use FirePHP and echo something beforehand. This might even be a whitespace before the
<?phptag. FirePHP sends all its content as a header, and headers can’t be send after any output is made.Since I’m sure that you call FirePHP in your
do_the_silent_slow_stuff_Now();method I recommend not to use buffering, flushing and FirePHP at once.Either you resign on
ob_start()andob_flush()during the development phase or you call theob_flush()method after all stuff is done.Third possibility would be to seperate your development and live phase by doing something like
$development = true;and make your own FirePHP function:and:
Hope this helps!