Re: Nesting level too deep - recursive dependency?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* 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."

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux