i'm trying to call a getter of an object dynamically (the getter is in a string) but it won't work:
$getterName = "get" . $name; //creation of the getter name like getFirstname
$value = call_user_func(array($player, $getterName()));
$player is an instance of myBundle\Entity\Player I'm running this code in a controller of another symfony bundle.
My error:
Uncaught PHP Exception Symfony\Component\Debug\Exception\UndefinedFunctionException: "Attempted to call function "getFirstname" from the global namespace."
I don't know how to solve this, does someone have an idea ?
Thanks