How can I call a class's static method, when the method I want to call is stored in a variable?
For example:
$action = "myMethod";
MyClass::$action("some argument");
Which could result in the same as doing this:
MyClass::myMethod("some argument");
You do that in this way:
call_user_func(array('MyClass', $action), 'some argument');
References:
I am not quite sure if you're talking about Delegates or not. But Storing a function/method in a Variable is called Delegates. I will post 2 examples.
require_once('classes.php');
$pkg = new Package("Heavy Package");
$pkg->setWeight(100);
$shipper = new ShippingDelegate();
if ($pkg->getWeight() > 99)
{
$shipper->useRail();
}
$shipper->deliver($pkg);
The first one has a parameter for the Method class. The Other One calls its class Constructor.
I hope this helps.