create_function() and anonymous methods

From: Date: Mon, 26 Jan 2004 19:10:21 +0000
Subject: create_function() and anonymous methods
Groups: php.general 
Request: Send a blank email to php-general+get-175792@lists.php.net to get a copy of this message
Hi again... I'm still curious about the question below, already posted several days ago... Marco 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 (#175792) next »