NYCPHP Meetup

NYPHP.org

[nycphp-talk] function references

csnyder chsnyder at gmail.com
Sun Jan 11 14:11:43 EST 2009


On Sun, Jan 11, 2009 at 1:34 PM, Hans Zaunere <lists at zaunere.com> wrote:

>> $foo = new Bar();
>> $a = 'my_method';
>> $result = $foo->{$a}();
>>
>> Very useful sometimes.
>
> Yes, but indirection can easily be overused.  Please don't overuse as it
> makes reading other's code that much harder.
>

Hah, just imagining a project from hell that would define() all of the
method names in an include and then make calls like the following:

$result = $foo->{ MY_METHOD_1 }();

... because then if the foo interface ever changes, all you have to do
is update the include file. :-D



More information about the talk mailing list