tags:

views:

73

answers:

3

I'm getting a fatal "Call to a member function on a non-object" error in a PHP script, but I'm unable to track down exactly where this is happening, or why. The error message is pretty-much useless, as the line it describes works 99.9% of the time.

Is there a way I can get the current call stack, trace what calls are being made before this fatal error, or do anything else to help track down this bug?

+1  A: 

Use this at the previous line of error:

var_dump(debug_trace);
Cem Kalyoncu
you can use <pre> tags to improve your output.
Cem Kalyoncu
+3  A: 

I would recommend installing Xdebug on your development server. It's a very valuable tool in cases like these.

Jani Hartikainen
A: 

Use debug_print_backtrace() - http://us2.php.net/manual/en/function.debug-print-backtrace.php

grantwparks