----- Original Message ----- From: "Stanislav Malyshev" <[EMAIL PROTECTED]> To: "Tim Daly, Jr." <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Thursday, October 17, 2002 5:34 PM Subject: Re: [PHP-DEV] trying to understand zvals
> 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. > -- I think he wants to know how to do that in C. Andrey -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php