开发者

Where do you include FirePHP in Wordpress?

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....'

开发者_C百科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 in page.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 though echo() 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

<?php
require_once(/FirePHPCore/FirePHP.class.php');
ob_start();
?>

at the top of your header file.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜