create_function() and anonymous methods

From: Date: Thu, 15 Jan 2004 12:38:46 +0000
Subject: create_function() and anonymous methods
Groups: php.general 
Request: Send a blank email to php-general+get-174638@lists.php.net to get a copy of this message
Hi all, Is it possible to use create_function() to define anonymous methods (like in Java) ? I mean something like: class Listener { function listen () { return 'I am an abstract method'; } } $listener = new Listener(); $listener->listen = create_function ( '', 'return "I am an anonymous method";' ); echo $listener->listen(); The above code doesn't work, "abstract method" is printed. I've read I could define a private variable that stores a function and use it inside a method. But it's not what I want: I want dynamically overload the methods of several already defined functions. Is there some way to do it? Thanks in advance for an answer. Marco.

« previous php.general (#174638) next »