开发者

$this php what is it mean [duplicate]

This question already has answers here: Closed 12 years ago.

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜