简体   繁体   中英

Firebug and FirePHP: I can not get any message to console

I have added FirePHP but I can not get message from the PHP file.

    <html>
<h1>Test</h1>

<?php

if ((include 'fb.php') == TRUE) {
    echo 'OK';
    }else{
    echo "nok";
    }

header("Content-type: text/HTML");

$data="my data";

var_dump($data);

    ob_start();

    FB::info('Hello, FirePHP');

    ob_end_flush(); 

    ?>
    </html>

code is stripped down and very simple. When I load the page the include message (ok) and the variable $data can be seen.

But the FB::info() does not show up in the console.

Include works so lib fb.php is included. FirePHP is enabled

I have installed FF developer and FireHP extension

What can I do?

First make sure the FirePHP extension is working by going to http://firephp.org/ and enabling it. You should see messages in the FirePHP console.

Your code is likely sending output before FirePHP can send the response headers which is a problem. You need to start buffering the output at the very beginning of the script so that FirePHP can send the headers at the end.

Something like the following should work:

<?php
  ob_start();
  include 'fb.php'
  header("Content-type: text/HTML");
?>

<html>
<h1>Test</h1>

<?php
  $data = "my data";

  var_dump($data);

  FB::info('Hello, FirePHP');
?>

</html>

<?php
  ob_end_flush();
?>

You can also configure PHP to automatically buffer output and flush it at the end. That way you can omit the ob_*() calls. You can even configure PHP to auto-include fb.php so that you do not need to include it in every script.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM