Re: RE: PHP 4.0 Bug #6193 Updated: new object makes a shallow copy

From: Date: Fri, 18 Aug 2000 21:21:01 +0000
Subject: Re: RE: PHP 4.0 Bug #6193 Updated: new object makes a shallow copy
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-29542@lists.php.net to get a copy of this message
AL>> $a=1; AL>> function foo(&$b) { $b=2; ... AL>> changes $a and $b to 2, why shouldn╢t then AL>> $a=1; AL>> function foo(&$b) { $b=&$c; AL>> $a and $b and $c referenced afterwards? Because, as I explained already, references are not pointer, they are symbol table bindings. The "b" entry in symbol table can point to only one zval. Here I explain again: Before $b=&$c: Symbol table Zvals a -------------- zval(int,1) b -------------/ c -------------- zval(something other) After $b =&$c: Symbol table Zvals a -------------- zval(int,1) b -------------\ c -------------- zval(something other) As you see, there's no way to re-bind $a to C - we don't even know about that symbol table inside a function! The only thing we know that somewhere in the blue exists other symbol table entry pointing to zval(int,1) - because reference count is 2. But having "b", we cannot find "a" and re-bind it to zval(something other) - we just have no way of doing this. -- Stanislav Malyshev stas@zend.com +972-3-6139665 ext.106

« previous php.dev (#29542) next »