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 a really old version of Zend Studio, however I know there are many people who are put off by the price.
Next chapter: Custom error handlers >>
Previous chapter: Backtracing your code
Home: Table of Contents