Return values by reference

From: Date: Sat, 23 Mar 2002 14:06:21 +0000
Subject: Return values by reference
Groups: php.dev 
Request: Send a blank email to php-dev+get-81666@lists.php.net to get a copy of this message
Hi, I am still stuck with my extension module. I'm not able to implement a function which returns a reference to an already existing variable. All I want to do is to write a function like this in C: function &return_reference() { global $a; return $a; } The only possibility I found is to do something like that: *return_value=*other_variable; ZVAL_ADDREF(other_variable); This seems to work but I think it can't be correct, because "return_value" now isn't really a reference to "other_variable". Both are pointing to the same value but not to the same zval-Container. So both variables have an own refcount. I have the bad feeling that this might lead to a crash. Please help me. I just need to know, how to write a ZEND_FUNCTION which returns a reference to a variable like the PHP-Function above. Or is there an already existing function in PHP which is doing something like this and which I can use as an example how to do it? -- Bye, K <http://www.ailis.de/~k/> [A735 47EC D87B 1F15 C1E9 53D3 AA03 6173 A723 E391] (Finger k@ailis.de to get public key)

« previous php.dev (#81666) next »