Home >Backend Development >PHP Tutorial >What does $this in thinkphp mean?

What does $this in thinkphp mean?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-08-04 09:20:151881browse

What does $this mean in thinkphp

Reply content:

What does $this mean in thinkphp

$this is the current object reference, which is from PHP and has nothing to do with thinkphp

represents the current object, which has different meanings in different places. It depends on the specific code. Also +1 for upstairs

$this must be a PHP keyword that appears inside the class class, indicating the current object. Generally, the current class calls its own properties and methods.

<code><?php
class demo
{
    public $name;
    
    public function __construct($name='')
    {
        $this->name = $name;  //这里的$this 就是当前对象,就是本身的属性 赋值
    }

}
</code>

Current object reference

This object, $a = new Name(); $a->fun this is the object $a

$this is this object,

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn