note 96604 deleted from functions.anonymous by danbrown

From: Date: Mon, 08 Mar 2010 16:35:42 +0000
Subject: note 96604 deleted from functions.anonymous by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-166789@lists.php.net to get a copy of this message
Note Submitter: Alexander Podgorny ---- I took advantage of anonymous functions added in PHP 5.3 and created a javascript-like extension system for php making the following syntax possible: <?php class A extends Object {}; A::extend(array( 'method3' => function($owner) { print 'method3'; } )); class B extends Object {}; B::extend('A'); $o1 = Object::construct(); $o1->method1 = function($owner) { return 'method1'; }; $o2 = B::construct(); $o2->method2 = function($owner) { return 'method2'; }; $o2->extend($o1); print $o2->method1(); // output: method1 print $o2->method2(); // output: method2 print $o2->method3(); // output: method3 ?> You can get code here: http://dot-php.blogspot.com/

« previous php.notes (#166789) next »