How can I get the call stack from Fatal Error?

I am getting a fatal error "Call to a member function on a non-object"

in a PHP script, but I cannot track down exactly where this is happening, or why. The error message is pretty unhelpful as the line it describes works 99.9% of the time.

Is there a way to get the current call stack, keep track of what calls are in progress before this fatal error, or do anything else to help track down this error?

+2


source to share


4 answers


I would recommend installing Xdebug on your development server. It is a very valuable tool in such cases.



+5


source


Use this on the previous error line:



var_dump(debug_trace);

      

0


source


please see my answer and others also for different possibilities

How to catch a fatal PHP error

Obviously this is partly related in the sense that it only catches a fatal error. You can modify the function to catch other types of errors. The starting point for this is:

if($error['type'] == 1){

      

These methods override the Xdebug output if the installation is already done.

Best regards, sahunzai

0


source


Use debug_print_backtrace()

- http://us2.php.net/manual/en/function.debug-print-backtrace.php

-1


source







All Articles