note 51133 added to function.aggregate-methods
| From: | aatantializedotdk at osu1 dot php dot net | Date: | Mon, 21 Mar 2005 11:12:51 +0000 |
| Subject: | note 51133 added to function.aggregate-methods | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-86737@lists.php.net to get a copy of this message | ||
You can use this to dynamicily add methods to a class
class foo {
function addMethod( $code ) {
$cname = uniqid("class");
eval( "class ${cname} { ${code} }" );
aggregate_methods( $this , $cname );
}
function bar() {
$this->addMethod( "function baz() { echo 'sha'; }" );
}
}
$bang = new foo();
$bang->bar();
$bang->baz();
----
Manual Page -- http://www.php.net/manual/en/function.aggregate-methods.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+51133
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51133&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51133&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51133&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51133&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51133&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+51133&report=yes
Search -- http://master.php.net/manage/user-notes.php