シナリオは次のとおりです。
メソッドの数が決まっていないクラスがあります。あるものはどこfunction actionName
で呼び出され、他のものはfunction filterName
どこ"filter"
で呼び出され、"action"
どのタイプのメソッドであるかを定義し、"Name"
何でもかまいません。
私__construct()
はしたい:
$methods = get_class_methods($this);
foreach ( $methods as $method ) {
if ( $method == 'action' )
$this->DoSomething( $this->{$method}() );
if ( $method == 'filter' )
$this->DoSomethingElse( $this->{$method}() );
}
どのタイプの文字列または reg 式も使用せずにこれを達成するにはどうすればよいですか?
また、 の代わりに使用することにもオープンですget_class_methods()
。しかし、メソッドがいくつ存在する"action"
かは決してわからないことを覚えておいてください。"filter"