The solution: Use a good debugger!
Recommendation: Xdebug (http://xdebug.org)
Some other debuggers: