note 11434 deleted from function.create-function by cmb

From: Date: Thu, 07 Jul 2022 14:38:52 +0000
Subject: note 11434 deleted from function.create-function by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-218921@lists.php.net to get a copy of this message
Note Submitter: mrben at free dot fr ---- Here is another tricky but usefull techynote, good for adding "plugin" to a existing class : <?php 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(); ?>

« previous php.notes (#218921) next »