I’m using require_once()
in header.php to include the FirePHP library. In the page.php I’m doing the usual…
$firephp = FirePHP::getInstance(true);
$firephp->log($categories);
Getting these errors..
'Headers already sent....'
and
Cannot send log data to FirePHP. You must have Output Buffering enabled via ob_start() or output_buffering ini directive...
I figured the using require_once in the template’s header.php (above all HTML output) would be safe (pre header output). Guess this is not the case.
Anyone have experience with this? (P.S. I tried the WP FirePHP plugin, wasn’t working right)
FirePHP uses the output headers to transfer debugging data to the browser. So the
require_once()
statement is not the problem, but the fact that you do logging inpage.php
, at which point HTML has already been output. Not only do you need to include FirePHP before any content has been sent – you need to also do all logging before sending content as well.The usual workaround is to hold any output to the browser using output buffering and the
ob_*
family of functions. That enables you to send out headers even thoughecho()
commands (and the likes) have already been issued.I am guessing doing all this safely is what the WP_FirePHP plugin was made for. I would recommend taking a second look at that plugin.
Put
at the top of your header file.