Re: PHP 4.0 Bug #2075: Self referential objects can't have more than two references to themselves

From: Date: Mon, 16 Aug 1999 21:29:51 +0000
Subject: Re: PHP 4.0 Bug #2075: Self referential objects can't have more than two references to themselves
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-9896@lists.php.net to get a copy of this message
return $next returns a copy of $next. You cannot return references from functions. Zeev At 22:14 16/08/99 , dom@recoil.org wrote:
From:             dom@recoil.org
Operating system: linux redhat 5.2
PHP version:      4.0 Beta 2
PHP Bug Type:     Other
Bug description:  Self referential objects can't have more than two references to themselves
Whenever I try to build a self referential structure, information is lost after two nodes in the chain. The following code shows that the structures can never be more than two nodes deep. <? class Test {
        var $next;
        function add($next)
        {
                $this->next = $next;
                return $next;
        }
        function dump()
        {
                echo "Test!<br>";
                $this->next->dump();
        }
} $test = new Test; $next = $test->add(new Test); $next = $test->add(new Test); $next = $test->add(new Test); $test->dump(); ?> This code causes the following error with both php3 and php4b2: Test! Test! Fatal error: Call to a member function on a non-object in /home/dom/public_html /treetest/test.php3 on line 19 Configure line was: ./configure --with-mysql --with-apache=../apache_1.3.6 --enable-track-vars --with-xml -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net For additional commands, e-mail: php-dev-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net
-- Zeev Suraski <zeev@zend.com> http://www.zend.com/ For a PGP public key, finger bourbon@netvision.net.il

« previous php.dev (#9896) next »