Friday, 13 September 2013

Call abstract class method from class name

Call abstract class method from class name

I have a string containing the name of a class. This class is abstract,
but has a public static method returning an instance of a child class.
abstract class MyClass {
public static function instance() {
return self::$inst;
}
}
Now I need to call this method somehow and all I am given is the name of
the class as a string. I can't say $class = new $className() because
MyClass is abstract. Any ideas?

No comments:

Post a Comment