note 10113 modified in function.create-function by aidan

From: Date: Sun, 20 Jun 2004 06:18:59 +0000
Subject: note 10113 modified in function.create-function by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-71392@lists.php.net to get a copy of this message
How do you use function which is created by create_function() as class method? <?php class Hoge { var $lamda; function set( $lamda ) { $this->lamda = $lamda; } function callLamda() { $func = $this->lamda; return $func(); } } $newfunc = create_function( '', 'echo "hoge<br>\n";' ); $h = new Hoge; $h->set( $newfunc ); $h->callLamda(); ?> It works fine. :-) --was-- HOw to use function which is created by create_function() as class method? I try: class Hoge { var $lamda; function set( $lamda ) { $this->lamda = $lamda; } function callLamda() { $func = $this->lamda; return $func(); } } $newfunc = create_function( '', 'echo "hoge<br>\n";' ); $h = new Hoge; $h->set( $newfunc ); $h->callLamda(); It works fine. :-) http://php.net/manual/en/function.create-function.php

« previous php.notes (#71392) next »