Answers for "php call method from string"

PHP
0

php call method from 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 method from string"

Browse Popular Code Answers by Language