TDJ>> I'm trying to do some extension programming, and I'm pretty confused TDJ>> by the whole zval thing. In particular, references are a little TDJ>> mysterious. If I have TDJ>> TDJ>> $foo = "zonk"; TDJ>> $bar =& $foo; TDJ>> TDJ>> in PHP, what actually happens? Specifically, if I wanted a function
What actually happens is that both entries in symbol table with names "foo" and "bar" point to the same zval (having refcount of 2 now) containing string "zonk". TDJ>> that did such a reference assignment: TDJ>> TDJ>> $foo = "zonk"; TDJ>> $bar = "baz"; TDJ>> TDJ>> ref_assign($bar, $foo); // $bar =& $foo; TDJ>> TDJ>> what has to happen in ref_assign? That's problematic, due to the way PHP variables work. The best you can do is something like this: function ref_assign($a, $b) { $GLOBALS[$a] =& $GLOBALS[$b]; } ref_assign("bar", "foo"); That's assuming they are globals. If they are not, I cannot now think of a good way to make variable-binding function. -- Stanislav Malyshev, Zend Products Engineer [EMAIL PROTECTED] http://www.zend.com/ +972-3-6139665 ext.109 -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php