views:

28

answers:

1

Hi,

I'm curious if anyone knows how I can save the current state of a php application (the one that is currently in memory, with everything including declared variables, $_POST, $_GET) when an error occurs?

Currently Zend Server does this. by monitoring the application and saving the snapshot of the php's memory etc. and shows a log related to that?

I'm not even sure if I'm using the right keywords. It's like debugging the application where you can see the values of the variables defined in the php. I just need the state of all the variables for that moment (which an error occurs).

thanks.

+1  A: 

Xdebug does something similar to what you're describing when an error is encountered.

alt text

You may be able to replicate this without Xdebug or Zend Server using functions like get_defined_vars() and memory_get_usage()

Mike B
get_defined_vars() only returns the variables in the current scope. So if I call it in a function it will only return the variables in that scope and not the previous scope (the one who called the function). But I guess using debug_backtrace() and get_defined_vars() will have to be enough.thanks
radalin