PHP: variable name as class instance

tdmpost

New Member
Hey guys, Im having a problem with using a variable as the class name when calling a static function within the class. My code is as follows: \[code\]class test { static function getInstance() { return new test(); }}$className = "test";$test = $className::getInstance();\[/code\]Ive got to define the class name to a variable as the name of the class is coming from a database so i never know what class to create an instance of. note: currently i am getting the following error: \[code\]Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM \[/code\]Thanks
 
Back
Top