note 11434 added to create_function

From: Date: Wed, 21 Feb 2001 01:33:11 +0000
Subject: note 11434 added to create_function
Groups: php.notes 
Request: Send a blank email to php-notes+get-11319@lists.php.net to get a copy of this message
Here is another tricky but usefull techynote, good for adding "plugin" to a existing class : <? class Hoge { var $lamda; var $text; function set($lamda) { $this->lamda = $lamda; } function callLamda() { $func = $this->lamda; return $func($this); } function get() { return $this->text; } } $newfunc = create_function('&$class', 'echo $class->get();' ); $h = new Hoge; $h->text = "Hi there !"; $h->set($newfunc); $h->callLamda(); ?> http://www.php.net/manual/en/function.create-function.php

« previous php.notes (#11319) next »