Re: strange stuff in a class

From: Date: Wed, 10 Jul 2002 10:03:20 +0000
Subject: Re: strange stuff in a class
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-106740@lists.php.net to get a copy of this message
Привет!
<?php class test {
    function test() {
      $globals['test2'] = &$this;
    }
} $test1 = new test(); ?> The problem hier is that $globals['test2'] is a copy of $globals['test1'] not a references.
It is, but you are looking in the wrong direction. the copy is in test1, test2 holds the reference. This should work: <?php
class test {
    function &test() {
      $globals['test2'] = &$this;
    }
} $test1 = new test(); ?>
To output a reference instead of a copy a function *must* be declared with an &. Not sure whether you might also need it here: $test1 = new &test(); check it out пока Альберто Киев @-_=}{=_-@-_=}{=_-@-_=}{=_-@-_=}{=_-@-_=}{=_-@-_=}{=_-@-_=}{=_-@ LoRd, CaN yOu HeAr Me, LiKe I'm HeArInG yOu? lOrD i'M sHiNiNg... YoU kNoW I AlMoSt LoSt My MiNd, BuT nOw I'm HoMe AnD fReE tHe TeSt, YeS iT iS ThE tEsT, yEs It Is tHe TeSt, YeS iT iS ThE tEsT, yEs It Is.......

« previous php.general (#106740) next »