Delicious Bookmark this on Delicious Share on Facebook SlashdotSlashdot It! Digg! Digg



PHP : Function Reference : Classkit Functions : classkit_method_add

classkit_method_add

Dynamically adds a new method to a given class (PECL classkit:0.1-0.4 runkit:0.7-0.9)
bool classkit_method_add ( string classname, string methodname, string args, string code [, int flags] )

Example 390. classkit_method_add() example

<?php
class Example {
   function
foo() {
       echo
"foo!\n";
   }
}

// create an Example object
$e = new Example();

// Add a new public method
classkit_method_add(
   
'Example',
   
'add',
   
'$num1, $num2',
   
'return $num1 + $num2;',
   
CLASSKIT_ACC_PUBLIC
);

// add 12 + 4
echo $e->add(12, 4);
?>

The above example will output:

16

Change Language


Follow Navioo On Twitter
classkit_import
classkit_method_add
classkit_method_copy
classkit_method_redefine
classkit_method_remove
classkit_method_rename
eXTReMe Tracker