2012-03-15 7 views
0

データをIndexメソッドに渡しますが、メソッドがそのように呼び出された場合、どのように渡すのですか?メソッドにデータを渡す方法

if (method_exists($controller, $method)) { 
    $controller->{$method}($controller); 
} else { 
    $controller->Index('test'); 
} 
+0

物体$objからsome_funcという名前のメソッドを呼び出すhttp://stackoverflow.com/questions/771036/php-equivalent -of-send-and-getattr – PasteBT

答えて

1

代わりにcall_user_func_array()を使用できます。

例:

call_user_func_array(array($obj, 'some_func'), array('a', 'b')); 

上記のコードは2つのパラメータ'a'及び'b'

関連する問題