Hi there everyone,

I'm very low on the totem pole of PHP scripters, so I've always debugged by running the script and then looking through the offending code when it errors out. It takes a bit of time sometimes to find it, but eventually I end up seeing what I did wrong.

In one of the articles on my news feed this morning, it discussed debugging your scripts with FirePHP, but to be honest, it seems like it might be intended for a much higher class of scripter. The article raised more questions than it answered in regards to who should be using it and why.

So, I'm wondering what, if anything you guys are using to debug your scripts? Do you simply run it and drill through the code until you find the problem or are you using something like this? If you are, can you tell me what and what the benefits are?

Thanks very much for your time,
json

    I use FireBug for viewing my HTTP information and debugging JS. For PHP, my editor generally tells me of a syntax error ... if not, trial and error is my best friend and I've been doing this for over 7 years.

      I'd never heard of it until now, but I just downloaded/installed it and played around with it a bit, and it looks to be pretty cool.

      Test PHP script:

      <?php
      ob_start();
      require_once 'lib/FirePHPCore/FirePHP.class.php';
      $fb = FirePHP::getInstance(true);
      ?>
      <html><head><title>Test</title></head><body>
      <h1>Hello, World!</h1>
      <?php
      $var = "This is a test";
      $fb->log($var, 'Test');  // this will show up in FireBug console
      ?>
      <p>The end</p>
      </body></html>
      

      Resulting browser output/console shown in attachment:

        I've been using Firebug lately, mainly for debugging CSS. It seems to be fairly useful, but I still go back and forth from the code to the browser trying to find out the issue.

          Randy Jackson;10921547 wrote:

          I've been using Firebug lately, mainly for debugging CSS. It seems to be fairly useful, but I still go back and forth from the code to the browser trying to find out the issue.

          The FirePHP add-on gives you the ability to have your PHP scripts output errors and/or debug info in the Firebug console (as opposed to in the actual HTML output and/or log files on the server). So if you're already using Firebug and doing PHP development, it might be worthwhile looking further into FirePHP.

            NogDog;10921549 wrote:

            The FirePHP add-on gives you the ability to have your PHP scripts output errors and/or debug info in the Firebug console (as opposed to in the actual HTML output and/or log files on the server). So if you're already using Firebug and doing PHP development, it might be worthwhile looking further into FirePHP.

            I may well try it for my next PHP project. My current contract is all Coldfusion, however.

              12 days later

              I used Firebug for a while but didnt get much out of it -
              I much prefer the "WebDeveloper" add on as its easier to use for debugging css/html display oddities

              but I guess I'd better try FirePhp

                I use Firbug for js and it is great for that. Mind you, I don't do enough web work to justify a full-blown dev platform. I'm sure if I did then I'd find one with built-in js debug etc.

                  6 months later

                  I don't think I could get by without FirePHP.

                  It's SO much nicer than print_r() for seeing what's in objects/arrays.

                  I can literally just LITTER my code with sample debugging output all over the place: queries that have been assembled, database returns, arrays that have been populated...nevermind the AWESOME per request Ajax analyzer!

                  Then, when it's all sorted out and time for the production server?

                  $firephp->setEnabled(FALSE); // just turns it off!

                  In one of the articles on my news feed this morning, it discussed debugging your scripts with FirePHP, but to be honest, it seems like it might be intended for a much higher class of scripter. The article raised more questions than it answered in regards to who should be using it and why.

                  Re-read it until you figure it out. Do some experiments with the different functions and learn how to use this invaluable tool!

                    Write a Reply...