note 10113 modified in function.create-function by aidan
| From: | aidan@php.net | Date: | Sun, 20 Jun 2004 06:19:08 +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-71393@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 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. :-)
http://php.net/manual/en/function.create-function.php