Does $this in PHP represent the current class or method?
A _ Q _i_
A _ Q _i_ 2021-10-10 19:51:03
0
5
968
class DBmodel{
    private $name;
    publice function delete($name){
        $this->name = $name;
    }
}

Does $this inside represent the entire class DBmodel, or the class method delete?

A _ Q _i_
A _ Q _i_

reply all(2)
逆旅行人

$this represents an object, and the environment where $this is located is inside the method inside the class, so the $this object is accessed inside the class

A _ Q _i_

Does $this in

//如果里面有构造方法:
function __construct(){
$this->name = $name;
}

represent the constructor method itself?

  • reply $this->name represents the name attribute in this class
    autoload author 2021-10-14 09:49:31
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template