0

私はしばらくの間、これに悩まされてきました。ここで完全なレンガの壁にぶつかりました。メソッド名からメソッドに関する情報を収集しようとしています。しかし、php は getMethod() について知りません。これは、php の「リフレクション」の一部である必要があります。(http://www.php.net/manual/en/reflectionclass.getmethod.php)リンクで、この男はエラーをスローすると述べていますが、これは私の場合のようですが、答えはありません.. .

私の場合、コードは次のようになります。

$params = $controllerInstance->getMethod($methodName)->getParameters();

クラスは次のようになります。

class accountController extends controller{

    public function createUser(account $accountModelInstance){
        return "this is a response!";
    }

}

私はこれを恐れています:

class accountController extends controller{
    public function getMethod(string method){
        return this->{method};
    }
}

気になる場合は、postgreSQL プラグインを使用してWAMP サーバーを実行しています。

4

1 に答える 1

3

ReflectionClassクラスです。何も定義せず、それを使用するだけです:

$class = new ReflectionClass($controllerInstance);
$params = $class->getMethod($methodName)->getParameters();

できます!

于 2013-09-30T20:48:35.070 に答える