Re: Nesting level too deep - recursive dependency?

From: Date: Wed, 20 Oct 2004 00:12:11 +0000
Subject: Re: Nesting level too deep - recursive dependency?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-199889@lists.php.net to get a copy of this message
* Thus wrote Francisco M. Marzoa Alonso: > This code: > > <?php > > class TestClass { > public $myself; > > function __construct () { > $this->myself = $this; > } > } > > $TestObj = new TestClass (); > > if ( $TestObj->myself == $TestObj ) { > echo "They are same.\n"; > } Since comparing objects is comparing all the attributes: first php compares the $myself attrib for both objects: $TestObj->myself->myself == $TestObj->myself In order to see if those two myself's compare php needs to compare all of those attributes: $TestObj->myself->myself->myself == $TestObj->myself->myself ...And so on... PHP Detected this and threw and error. Curt -- Quoth the Raven, "Nevermore."

« previous php.general (#199889) next »