0

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?

Humbarzel
  • 1
  • 2
  • Make sure you can see any errors that might be occurring ~ [How can I get useful error messages in PHP?](https://stackoverflow.com/questions/845021/how-can-i-get-useful-error-messages-in-php) – Phil Oct 30 '19 at 22:17
  • Also, your `header()` after `echo` will be causing a _"headers already sent"_ warning – Phil Oct 30 '19 at 22:17

1 Answers1

0

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.

cadorn
  • 369
  • 1
  • 7
  • 1
    Hi Gents, shame on me its working now. The problem was simply that I missinterpreted the Enable/Disable button in firePHP. I thought when it says "enable" that the firePHP is in enabled state. Its the other way round. Now the button is green and says "disable". But I have learned something about PHP error messages. I have turned on error messaging and can better debug now. – Humbarzel Oct 31 '19 at 23:22
  • A new QuickStart guide has been added to the FirePHP website: http://firephp.org/quickstart.php – cadorn Dec 24 '20 at 06:32