php - Can I integrate functions with same content, different names?

Posted by Gal on Stack Overflow See other posts from Stack Overflow or by Gal
Published on 2010-03-26T22:49:06Z Indexed on 2010/03/26 22:53 UTC
Read the original article Hit count: 305

Filed under:
|
|
|
|

I have a couple of functions inside a class that essentially do the same thing:

public function fn_a(){
        return __FUNCTION__;
}
public function fn_b(){
        return __FUNCTION__;
}
public function fn_c(){
        return __FUNCTION__;
}

I need those functions to remain in their current names so I intentionally did not do:

public function fn_($letter){
        return __FUNCTION__.$letter;
}

I was hoping for some sort of way to minify the verboseness of code here, since they all do the same. The ultimate situation would be something like this:

public functions fn_a, fn_b, fn_c() {
      return __FUNCTION__;
}

Another solution, if applicable, might be doing something like Class's "extends": fn_b, fn_c extend fn_a?

What do you think guys?

© Stack Overflow or respective owner

Related posts about php

Related posts about functions