Accessing private from static method in PHP

Why this works? I mean, accessing the private variable.

class Test {
    private $q = 0;
    public function __construct() {
        $this->q = 1;
    }
    public static function EpicConstruct() {
        $test = new self();
        $test->q = 2;
        return $test;
    }
}

$test = Test::EpicConstruct();

因为您正在以正确的上下文访问成员,即:定义私有成员的类。

链接地址: http://www.djcxy.com/p/69432.html

上一篇: Joomla Parse错误:语法错误,意外的T

下一篇: 在PHP中使用静态方法访问私有