tags:

views:

31

answers:

1

I was trying to use array_walk_recursive for something, and wanted to use one of the class' methods as the call back, so trying:

  array_walk_recursive($TAINTED, "$this->encode()");

and variations thereof all failed. I eventually settled for:

array_walk_recursive($TAINTED, 'className::encode');

which works, but I've read on here that calling class methods in a static fashion like this is often considered poor practice. Or is this one of those situations where it's necessary?

So, is this the right way to go about it, or is there a way to put in the callback function without having to fall back on using it as a static class method?

+3  A: 
array_walk_recursive($TAINTED, array($this, 'encode'));
webbiedave