ignus Posted July 21, 2009 Share Posted July 21, 2009 I apologize if the title is not exactly accurate, but my head just goes nuts when I try to think how would I name what I want to do, as a programmer, its always easier with code: $dataMapper = $yay . "_something"; $dataMapper::getInstance(); //this is want I want to do, but is not valid The classes I want to load are all singleton. I know it may be easier to implement something like a Registry but I want to do it this way (plus, I dont have that many different class names, so maybe it's not worth it) Thanks for the help Link to comment https://forums.phpfreaks.com/topic/166743-variable-class-name-static-method/ Share on other sites More sharing options...
btherl Posted July 21, 2009 Share Posted July 21, 2009 I believe php 5.3.0 and greater can do this. Otherwise you'll have to kludge it somehow, perhaps with a lookup table mapping names to class instances. http://www.php.net/manual/en/language.oop5.paamayim-nekudotayim.php Link to comment https://forums.phpfreaks.com/topic/166743-variable-class-name-static-method/#findComment-879298 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.