Selecting class using strings
I want to write an extension system for my CMS. I want the extensions to be installed by copying a folder into the extensions folder. The content of the extension is a class with the same name as the name of the folder. So my CM开发者_如何学GoS can list the extensions by the names of the folders in the extension folder. The problem is that I can't find a way to select the class even though I have a string containing it's name.
So to sum up, is there any way to create an instance of a class or calling static functions of a class, by referring to said class using a string with the class name?
I hope you understand what I mean and thanks for any help
You mean like so?
$classname = "myClass";
$object = new $classname();
精彩评论