Firebug: Add Browser-based Debugging to Your Ajax Development, Page 2
Debugging PHP Code with FirePHP
Firebug has become such a widespread fixture within the Web developer's toolbox that an extension ecosystem has begun to form (Think of it! Extensions for the extension!). If you're a PHP developer, consider installing FirePHP, a Firebug extension that allows you to accompany HTTP payloads returned from a PHP script with debug information originating within PHP!
When you have FirePHP installed, you can begin inserting log messages into your PHP scripts, as demonstrated here:
require_once('FirePHP.class.php'); $firephp = FirePHP::getInstance(true); $battles = array(); $battles = array ( "name" => "Shiloh", "date" => "April 6-7, 1862", "location" => "Hardin County, Tennessee", "latitude" => 35.1525, "longitude" => -88.323056 ); $firephp->log($battles, 'Battle #1');
Executing this script within the browser produces the log message in Figure 4.
Figure 4. Logging Array Contents with FirePHP: Here is the result of executing the above script within the browser.
Other Useful Firebug Extensions
In addition to FirePHP, I suggest taking a look at the Firebug's other available add-ons, including:
- Firecookie: FireCookie adds a cookie management tab to Firebug's interface, allowing you to easily examine the number and content of cookies stored by a particular website.
- YSlow: YSlow analyzes your Web page for performance issues and makes suggestions for improvement based on the result.
As a developer, your job is to create useful applications, not waste time with inconvenient code-debugging techniques. So why not make sure you have the best tooling available, starting with Firebug! If you use other tools for debugging website code, tell us about them in the comments!
About the Author
Jason Gilmore is the founder of EasyPHPWebsites.com. He also is the author of several popular books, including "Easy PHP Websites with the Zend Framework," "Easy PayPal with PHP," and "Beginning PHP and MySQL, Third Edition."
Page 2 of 2