lundi 13 février 2017

Php, I cant access inherited private variables not even with reflection

class A
{
    private $a;
}

class B extends A
{
    function __construct()
    {
        (new \ReflectionClass($this))->getProperty('a')->setAccessible(true);
        echo $this->a;
    }
}

(new B());

this should work, altough it triggers an exception: "property a doesnt exists". Many articles says Reflection is the sollution





Aucun commentaire:

Enregistrer un commentaire