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/

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to