$this php what is it mean [duplicate]
Possible Duplicate:
What does the variable $this mean in PHP?
I 开发者_开发百科see a lot of $this in php and oop programming. What is it?
When used in a class, $this
refers to the class instance. You need to use it to access class members (not global, or local -- their scope is confined to the class).
refers to the object it is referenced within. so if your object's class has a method called blah(), in another method in that class you might use $this->blah() to call the other method.
It refers to the current instance of the class you are in
$this refers to the active class and is used to access methods and properties within the active class. Likewise you can use self for static methods and properties.
I suggest you give this a read > http://www.php.net/manual/en/language.oop5.basic.php
精彩评论