On Tuesday 26 September 2006 06:32 am, Prometheus Prometheus wrote: > [EMAIL PROTECTED] > > 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 > > example: > class A{ > public function __construct(){} > public function __destruct(){ > // here i want the return value like: > $retval = idontknowwhichfunction(); > print $retval; // this print's "test" > } > } > > function B(){ > $classvar = new A(); > > return "test"; > } > > 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 > > another option for this, would be just debugging of such applications > cause it can be boring to debug big applications and with such a > possibility i can reproduce the problem very fast and at any point > within my application > > 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? > 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? > Q3: anybody has another idea for such a "testing" or debugging > environment? the main advantage of such a system would be: i can > start debugging from any point within my code and i could very easily > create automated test's which can compare the result (what it is and > what it should be) "automated" > > [EMAIL PROTECTED] Oh sweet, something I know!
Return values are stored in zval *return_value. That's within any function that follows the Zend format (i.e. ZEND_FUNCTION() macro to declare it, returns value via the RETURN_*() macros). -- Matt Sicker
pgpfOUBVgNg0c.pgp
Description: PGP signature