ID: 38866 Updated by: [EMAIL PROTECTED] Reported By: adam at sccode dot com -Status: Open +Status: Feedback Bug Type: Class/Object related Operating System: Windows 2000 PHP Version: 5CVS-2006-09-18 (snap) New Comment:
After this change I get only bool(false). What is the problem? Previous Comments: ------------------------------------------------------------------------ [2006-09-18 15:21:14] adam at sccode dot com Apologies ... I posted the wrong reproduce code: private function __construct() { $this->me = $this; } Should read: private function __construct() { self::$instance = $this; } In previous versions of PHP this has produced no error. There are sometimes occasions where checking if two varaibles reference the same object instance is necessaary - I don't think a static property should break this. ------------------------------------------------------------------------ [2006-09-18 15:11:04] [EMAIL PROTECTED] With $this->attr = $this you get recursive references, so the error message is expected. ------------------------------------------------------------------------ [2006-09-18 14:37:19] adam at sccode dot com Description: ------------ Attempting to compare two variables containing a reference to an object instance which in turn contains a property static or otherwise, referring back to itself produces a "Nesting level too deep" fatal error. One example where a self references may be necessary is a singleton: in PHP 5.1.6 the reproduce code works as expected. A feature, or a bug? Reproduce code: --------------- $obj = Singleton::instance(); $obj2 = $obj; var_dump($obj != $obj2); class Singleton { private static $instance; private function __construct() { $this->me = $this; } public static function instance() { if (! self::$instance) { self::$instance = new Singleton; } return self::$instance; } } Expected result: ---------------- bool(false) Actual result: -------------- Fatal error: Nesting level too deep - recursive dependency? in crash-test.php on line 5 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=38866&edit=1