Re: $this variable reference question

From: Date: Sat, 03 Apr 2004 01:18:56 +0000
Subject: Re: $this variable reference question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-182224@lists.php.net to get a copy of this message
My question is actually regarding the line "$myref = &$this;". The author states that this is a reference to the class/object itself. Isn't this like saying outside the class "$myref =& new test;"? What would be the point of referring to itself inside the class in this manner? Thanks for your help in advance! -Adam Reiswig
The exact class that the author wrote isn't too useful, although it makes its point well. However, a reference to $this inside a class can be useful, for example, if you were using the observer pattern. http://www.phppatterns.com/index.php/article/articleview/27/1/1/

« previous php.general (#182224) next »