The solution: Use a good debugger!
Recommendation: Xdebug (http://xdebug.org)
- Open source
- Wide spreaded and used
- Integrates as a PHP extension
- Integration with IDEs (like Comodo)
- Support for profiling and code-coverage analysis
Some other debuggers:
- DBG http://dd.cron.ru/
- APD http://apd.communityconnect.com/
- Zend IDE (commercial) http://zend.com