Re: Nesting level too deep - recursive dependency?

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

 



I was looking at this before and I'm not even sure what you are trying to do.
For one, you are testing to see if the contents of a class variable are equal to a class instance:
$TestObj->myself == $TestObj


Which seems a logic equivalent to:
$TestObj->myself == TestClass()   ???

And in your class you are setting a class variable equal to the class it is in:
$this->myself = $this


The recursion may actually be occurring in the $this->myself = $this line, but PHP isn't throwing an error until the comparison line.

Perhaps the comments posted in this link will help, it seems to explain the exact symptom you are getting:
http://php.planetmirror.com/manual/en/language.oop.object-comparison.php


On Oct 18, 2004, at 11:16 AM, Francisco M. Marzoa Alonso wrote:

Can someone tell me if I should fill a bug report about this or is it my fault???

Francisco M. Marzoa Alonso wrote:

This code:

<?php

class TestClass {
    public $myself;

    function __construct () {
        $this->myself = $this;
    }
}

$TestObj = new TestClass ();

if ( $TestObj->myself == $TestObj ) {
    echo "They are same.\n";
}

?>

Gives me a "Fatal error: Nesting level too deep - recursive dependency?"
on line #13: if ( $TestObj->myself == ...)


Could this be a PHP bug or I'm doing something wrong?

FYI:

PHP Version 5.0.2
PHP API 20031224
PHP Extension 20040412
Zend Extension 220040412
Server API Apache 2.0 Handler


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


--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search & Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577

--
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