Re: Re: PHP 4.0 Bug #3647 Updated: Change to Global variable in Function Fails

From: Date: Thu, 01 Jun 2000 14:46:33 +0000
Subject: Re: Re: PHP 4.0 Bug #3647 Updated: Change to Global variable in Function Fails
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-19974@lists.php.net to get a copy of this message
AP>> You have to be kidding me!?!? This is still a bug. The variable was No, I'm not kidding you and this is not a bug. Declaring variable as "global" makes local variable to be pointing to global one (like, $var = &$GLOBALS["var"]). Unsetting this local one is unsetting this local one, but the global one doesn't vanish. However, if you change it, global value gets changed, because local one is pointing to global one. But, if you assign to it a new reference, old one gets removed, so you again might not get what you expect. I know, this is not easy to understand, but that's the way references work in PHP now. You can read Andi's article on reference counting at http://www.zend.com/zend/art/ref-count.php to get more understanding of this. Or read the source (not for the faint of heart). AP>> declared as GLOBAL, so I shouldn't have to use the $GLOBALS array to set AP>> *or* *unset* it. Well, you can try and sue PHP Group over violation your rights not to use $GLOBALS, but this is how it presently works in PHP. If you don't like it, submit feature/change request. I just trying to hel you to make it work now. -- Stanislav Malyshev stas@zend.com +972-3-6139665

« previous php.dev (#19974) next »