[PHP-DEV] Feature request: object method passed as valid call back function pointer From: Manuel Lemos (mlemos <email protected>)
Date: 12/02/98

Hi,

I wasn't sure in which list to post, so I posted in both PHP users and
developers lists.

Often, I realize that it would be convinient if I could pass an argument
that would be used as a call back function. Currently I can only do that
if the argument is a string with the name of a globally visible function.

It would be great if I could call functions that are methods of objects.
Let's say I have the following definition:

Function some_function($object,$callback)
{
   $object->$callback($arguments); /* PHP doesn't allow me to do this */
}

In classes, where $object is mentioned $this could be used if needed.

This would come right in time with XML support in the upcoming PHP version
3.0.6, where we have to pass global functions as parser event handlers. Than
it would be easier to have PHP classes as wrappers for parsers of whatever
XML formats we wanted to support.

If passing object methods as arguments could be used it would be even
better if you could pass a function as argument but in the scope of a given
object, meaning we would call:

some_function($object::MethodName);

and in

Function some_function($callback)
{
  $callback($arguments);

  /* Would call the method named MethodName in the scope of the object referenced
     by the variable $object in the point where some_function is called. */
}

What do you think?

Regards,
Manuel Lemos

E-mail: mlemos <email protected>
URL: http://www.e-na.net/the_author.html
PGP key: finger://mlemos <email protected>

--

-- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe <email protected> For help: php-dev-help <email protected>