Page 1 of 1

Variable class name, static method

Posted: Mon Jul 20, 2009 8:39 pm
by ignuss
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:

Code: Select all

 
$dataMapper = self::DATAMAPPER_PREFIX . "_something";
$this->setMapper($dataMapper::getInstance()); //this line gives error
 
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

Re: Variable class name, static method

Posted: Mon Jul 20, 2009 11:42 pm
by requinix
I don't think there's a way of doing it with just variable-variable syntax, so

Code: Select all

$this->setMapper(call_user_func(self::DATAMAPPER_PREFIX . "_something::getInstance"));