I'm Tom. For example, I have read the source code of a website written in tp and written a module with an export action {code ...} what is the $ this here indicating which object and what values are there? I don't know when the $ this represents the object will be taken as an instance... I am a little white. Sorry,
For example, I read the source code of a website written in tp and wrote a module containing an export action.
Class ExamAction extends BaseAction {public function export () {$ this-> isLogin (); // determine whether to log on $ str = $ this-> getProSubStr (); $ sid = session ('studentid'); $ this-> navtop (); $ this-> getSub (); // assign a value to the page ...}}
What is the $ this here indicating which object and what values are there?
I don't know when the $ this represents the object will be instantiated...
Reply content:
I'm Tom. Sorry,
For example, I read the source code of a website written in tp and wrote a module containing an export action.
Class ExamAction extends BaseAction {public function export () {$ this-> isLogin (); // determine whether to log on $ str = $ this-> getProSubStr (); $ sid = session ('studentid'); $ this-> navtop (); $ this-> getSub (); // assign a value to the page ...}}
What is the $ this here indicating which object and what values are there?
I don't know when the $ this represents the object will be instantiated...
Generally$this
It is the instance of your class. After the outer function is new to the class object, you can call the non-static method of this class.$this
Because it is in the definition of your class.
Of course, the inner function does not know when it is called, but as a class method, it knows$this
The reference will be passed in like a common parameter.
In PHP5, the keyword "$ this" is introduced to resolve variable naming conflicts and uncertainty.
$ This indicates the new object created by the constructor.
To use the attributes and methods of the current object in a class, you must use the $ this-> value.
The local variable in the method, not an object, does not use the value of $ this.
For local variables and global variables and the $ this keyword, the $ this keyword must be used for attributes of the current object. Local variables are valid only in the method of the current object, so they are directly used.
This is a pointer to the current object.
String get_class ([object $ obj])