note 96604 added to functions.anonymous
| From: | AlexanderPodgorny at osu1 dot php dot net | Date: | Sun, 07 Mar 2010 20:27:32 +0000 |
| Subject: | note 96604 added to functions.anonymous | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-166763@lists.php.net to get a copy of this message | ||
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/
----
Server IP: 69.147.83.197
Probable Submitter: 99.55.172.210
----
Manual Page -- http://www.php.net/manual/en/functions.anonymous.php
Edit -- https://master.php.net/note/edit/96604
Del: integrated -- https://master.php.net/note/delete/96604/integrated
Del: useless -- https://master.php.net/note/delete/96604/useless
Del: bad code -- https://master.php.net/note/delete/96604/bad+code
Del: spam -- https://master.php.net/note/delete/96604/spam
Del: non-english -- https://master.php.net/note/delete/96604/non-english
Del: in docs -- https://master.php.net/note/delete/96604/in+docs
Del: other reasons-- https://master.php.net/note/delete/96604
Reject -- https://master.php.net/note/reject/96604
Search -- https://master.php.net/manage/user-notes.php