为什么我们可以使用代码$ this->在system / library / customer.php中

时间:2015-08-03 03:46:55

标签: opencart2.x

请查看以下代码:

public function __construct($registry) {
        $this->config = $registry->get('config');
        $this->db = $registry->get('db');
        $this->request = $registry->get('request');
        $this->session = $registry->get('session');

我的问题是属性$this->config$this->db,$ this->请求和$this->session未在此类中定义。而Customer类既不继承自另一个类,也没有实现__get(),__set()方法......

有人可以向我解释为什么我们可以在这里使用$this->吗?

1 个答案:

答案 0 :(得分:0)

这只是一个变量,它将在创建Object时声明并赋值,

尝试

class Test{

    function __construct(){
        $this->name = 'Ramesh';
    }
}
print_r(new Test());