PHP::如何在没有eval()的情况下用params调用类方法


PHP::How to call class method with params without eval()?

我有类名、方法名,还有一个带参数的数组。我想调用:"$class->method($param1,$param2,..);"

如果我用eval()来做,我就不能在PHP 5.2中使用get_called_class()函数(它在eval代码中找不到文件名)我需要调用widthout eval操作怎么做?

附言:我不知道参数的数量,我需要发送方法。。。

您可以使用call_user_func_array():

call_user_func_array(array($obj, $method_name), $args);