In thinkphp, how does one view the $ this class object?

Source: Internet
Author: User
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$thisIt 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.$thisBecause 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$thisThe 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])

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.