Hudzilla.org - the homepage of Paul Hudson
Contents > Writing PHP > Debugging Wish List | Report Bug | About Me ]

19.8.9     Debuggers

This is NOT the latest copy of this book; click here for the latest version.

No matter how good you are at using the debugging methods listed above, you are almost certainly much less effective at debugging than someone who is using debugging software to find their problems. While debuggers don't automatically point you to errors in your script, they do allow you to step through your code line by line, examine variables as you go, change the value of variables on the fly at runtime, check the contents of your output buffer, and more.

Of all these, just being able to select a line of your script and say "Execute until here" is the best. These script pause markers are called "breakpoints", and you can place as many of them as you want in your scripts. When the scripts are run through your debugger, it will automatically stop when the breakpoint is reached, allowing you to check the values of all the variables in your script to make sure things are going as you expect.

If you work on a project of any level of complexity over 100 lines of code, you should consider using a debugger, however there are three major debuggers to choose from: APD (the Advanced PHP Debugger), DBG, and the debugger built into Zend Studio.

APD, being part of PECL, is a free debugger developed by some of the programmers who work on PHP itself, but it has yet to catch on in the community. I think this is likely to change once it has settled in a little more.

DBG is a long-running free debugger, and is fully integrated both the PHP Edit and PHP Coder IDEs

The Zend Studio debugger is also fully integrated, but it is arguably easier to use thanks to the smart Zend Studio interface. When I want to debug some PHP, I use Zend Studio, however I know there are many people who are put off by the price.







<< 19.8.8 Backtracing your code: debug_backtrace()   19.8.10 Custom error handlers: set_error_handler(), restore_error_handler(), and error_log() >>
Table of Contents
Want to see this stuff in print? PHP in a Nutshell takes the core topics covered here, adds in thousands of edits from the editorial team and myself, and combines them to make an unbeatable reference for PHP programmers at all levels.



My latest book has hundreds more tips on how to use PHP, Apache, and MySQL, plus Perl, Python, shell scripts, performance tuning, and more!



Top-right shadow
 
Bottom-left shadow Bottom shadow

Comments from other readers
Be the first to add a comment to this chapter!



Add comment
Please note that by posting a comment here you are committing it to the public domain. This is important so that others can make use of your code themselves, and also so that I can incorporate helpful notes directly into the main text. Comments are limited to 2000 characters in length.

If you are reporting an error in the content, please tell me directly.

Your name/email address:
Your comment:
 
Now, in order to verify that you're a real person, please answer this simple question: what is two plus one?
The answer is:
(please write in
numbers, eg 19)


Top-right shadow
 
Bottom-left shadow Bottom shadow