accessing class method from variable
Posted: Fri Sep 12, 2008 11:51 am
Hi,
How can I execute the method of a class that is passed via a variable?
e.g.
thus the accessing of it will be
or

How can I execute the method of a class that is passed via a variable?
e.g.
Code: Select all
// class
class M {
function send(){
}
}
$class_method = 'send'; // the method of class M
$test = new M();
Code: Select all
$test->{$class_method}()
Code: Select all
$test->{$class_method. '()'}