2008-04-27

For instance (more about functions as arguments)

So, passing functions as arguments by turning them into strings, that's fine I suppose for traditional functions. But what about object methods? How am I supposed to transform $obj->do_something() into a string that I can feed to another function? That is what I would like to know.

2 comments:

Joshua E Cook said...

The solution to passing an instance method as a functional parameter is documented in the manual. You use an array value like `array(&$obj,'do_something')` which is also how you would pass a static class method, substituting a string containing the class name for the object reference.

skillet-thief said...

hi ijoshua,

Thanks for your comment. I ended up figuring that out, about passing methods. I still find it rather cumbersome but I have to admit that it works.