[Typo3-dev] The meaning of an function of "$this"

Jacob Lindhardsen web at jacoblindhardsen.dk
Fri Jul 2 11:45:08 CEST 2004


Hi Martin				

Thank you, Masi.

"Within a class definition, you do not know under which name the object will be accessible in your program: at the time the Cart class was written, it was unknown that the object will be named $cart or $another_cart later. Thus, you cannot write $cart->items within the Cart class itself. Instead, in order to be able to access it's own functions and variables from within a class, one can use the pseudo-variable $this which can be read as 'my own' or 'current object'. Thus, '$this->items[$artnr] += $num' can be read as 'add $num to the $artnr counter of my own items array' or 'add $num to the $artnr counter of the items array within the current object'. "

- Jacob Lindhardsen (lindhardsen)

-----------------------
This thread is located in the archive at this URL:
http://typo3.org/documentation/mailing-lists/dev-list-archive/thread/53804/
					





More information about the TYPO3-dev mailing list