vendredi 9 décembre 2016

PHP Reflection with two calls

I am trying to archive some reflection in php. How can i make something like that. With my code i am getting following error:

Undefined property: A::$getB()->getStr()

class B{
    public function getStr(){
        return 'str';
    }
}
class A{
    public function getB(){
        return new B();
    }
}

$a = new A();
$method = 'getB()->getStr()';
echo($a->$method);





Aucun commentaire:

Enregistrer un commentaire