For instance I have a function:
function hello($name='') { echo "hello $name"; }
This function is not in any particular class. I can call it by just typing in hello();
But I'd like to also "put" it into a dumb class as a method just so I can call it, like so:
$class = new simpleClassForThePurposeOfPuttingUserFunctionsInIt;
registerFunctionIntoAClassAsAMethod('hello',$class);
$class->hello('Johan');
How do I define the class and how to code the registerFunctionIntoAClassAsAMethod($functionName,&$theClass) ?
This post has been edited by eek-1: Apr 1 2014, 03:48 AM
PHP How can I call a function like a method?