Answers for "php call class method by string"

PHP
0

php call class method by string

class Player {
    public function SayHi() { print("Hi"); }
}
$player = new Player();

call_user_func(array($player, 'SayHi'));
// or
$player->{'SayHi'}();
// or
$method = 'SayHi';
$player->$method();
Posted by: Guest on May-04-2021

Code answers related to "php call class method by string"

Browse Popular Code Answers by Language