Re: how is a return values stored?
| From: | Derick Rethans | Date: | Tue, 26 Sep 2006 16:16:46 +0000 |
| Subject: | Re: how is a return values stored? | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-25837@lists.php.net to get a copy of this message | ||
On Tue, 26 Sep 2006, Prometheus Prometheus wrote:
> i was just asking myself, if it is possible, to get the return value of a
> function after the function calls "return" (or throws an exception) and before
> the value is returned
Only through an extension.
> i thought it would be a very impressive function for that purpose
> for what i would need it:
> think about testing a big php application
> calling hundreds of functions and debugging them takes very long
> but if i could track the arguments (debug_back_trace() function) AND the
> return values (that's what i'm asking for) i could run a complete test and
> after this i could change the input values automated and compare it with the
> output i got before
Xdebug (http://xdebug.org) does this with trace files storing both
function/method name, parameters and return values to a file on disk.
See: http://xdebug.org/docs-settings.php#auto_trace
(and the 3 settings
after it in the docs)
> the question is:
> Q1: how is the return value (return or throw) stored within php?
> or another question would be: is it possible to write an extension which
> can retrieve every variable set within my php session? (i know of the security
> problems this produces, but until know, i'm evaluating if it can work) and
> would be the return value within this variables?
> any hint on this would be great!
> since it's possible to create a sandbox within php (runkit extension) i think
> it should be possible to get the return value (or exception object) before the
> calling function receives it, not?
Yes, this is possible with an extension. You would need to reimplement
the zend_execute function. Again, you can find on how to do that in the
Xdebug sources.
> Q2: maybe i didn't find it, but is there a finished php function which i can
> use like debug_back_trace but for the return value?
There is none.
regards,
Derick