Bug or Intended Behaviour?

From: Date: Wed, 15 Aug 2001 00:09:26 +0000
Subject: Bug or Intended Behaviour?
Groups: php.dev 
Request: Send a blank email to php-dev+get-63196@lists.php.net to get a copy of this message
Consider the following code <?php class foo { function foo() {} } function contains_static() { static $bar; echo '1'.$bar.'<br>'; $bar =& new foo(); echo '2'.$bar.'<br>'; } contains_static(); contains_static(); ?> When $bar is assigned as above (with a &), this outputs 1 2Object 1 2Object Clearly, the static variable loses its contend between the two calls. After removing the & the output looks as follows 1 2Object 1Object 2Object Now the question: Is this a bug and assignment to a static variable by reference should work, or is this intended behaviour since after the scope of contains_static() the reference count is decreased, and bla bla ? You can easily find argument for both variants, hence the question. -- Sebastian Bergmann Measure Traffic & Usability http://sebastian-bergmann.de/ http://phpOpenTracker.de/

« previous php.dev (#63196) next »