in Python, you can do something like this:
class SomeClass(object): pass s = SomeClass someClassInstance = s()
How could you achieve the same effect in PHP? As far as I understand, you can’t do this? It's true?
You can instantiate dynamic class names; just pass the class name as a string:
class SomeClass {} $s = 'SomeClass'; $someClassInstance = new $s();
Using reflection:
class SomeClass {} $s = new ReflectionClass('SomeClass'); $someClassInstance = $s->newInstance();
The best part about using reflection is that it throws a spectacular exception if the class does not exist.