- str_replace: documentation ( source)
<?php
class User
{
public function getName()
{
return "SomeName";
}
}
$result = [
'command' => 'getName()'
];
$command = $result['command'];
$command = str_replace('()','',$command);
$user = new User();
echo $user->{$result['command']}();