Feature request: object method passed as valid call back function pointer

From: Date: Wed, 02 Dec 1998 23:46:14 +0000
Subject: Feature request: object method passed as valid call back function pointer
Groups: php.dev 
Request: Send a blank email to php-dev+get-2642@lists.php.net to get a copy of this message
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@acm.org URL: http://www.e-na.net/the_author.html PGP key: finger://mlemos@zeus.ci.ua.pt -- -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#2642) next »