Hi all,
it might be a longshot, but I'm going to give it a try :
Suppose I have 3 classes :
MySQLDatabase
PostGresDatabase
MSAccessDatabase
All three extend from a Database class. Depending from the settings I want to use one of the three classes.
I have a variable $dbClass which holds the class to use, e.g. :
$dbClass = "MySQLDatabase";
Is there a way to create an object of the class using the variable, e.g. :
$database = new $$dbClass(); // won't work, is an example
I could offcourse use a switch statement, or name the class Database, and just change the class-file-name (and include the file based on the variable), but I need a way to do it without those tricks.
Is the no function like in java :
Class.getClass("com.jeropolis.MySQLDatabase").getInstance();
which returns an object for a class with a certain name?
Thanks in advance!
JEroen