note 23465 added to language.oop

From: Date: Fri, 19 Jul 2002 00:36:37 +0000
Subject: note 23465 added to language.oop
Groups: php.notes 
Request: Send a blank email to php-notes+get-33280@lists.php.net to get a copy of this message
Don't use $this to pass a reference to the current object in the object's constructor. class parent { var $child; function parent() { $this->child = new child(&$this); } } class child { var $parent; function child(&$parent) { $this->parent = &$parent; } } $parent = new parent(); for some reason $parent != $parent->child->parent if you need to pass a reference to child objects, use eg. an init-function, in which &$this will work just fine. Just don't use the constructor. -- http://www.php.net/manual/en/language.oop.php http://master.php.net/manage/user-notes.php?action=edit+23465 http://master.php.net/manage/user-notes.php?action=delete+23465 http://master.php.net/manage/user-notes.php?action=reject+23465

« previous php.notes (#33280) next »