alkativo: Dynamic class

Beitrag lesen

Tach!

how can I do something like this. With string the path is not working

According to Namespaces and dynamic language features it should ...

$class = 'Myclassname';
$class = '\Application\Modell\'.$table;
$object = new $class($this->getAdapter());

... but $class != $table. If this is not the reason please tell what "is not working" exactly means (error message).

dedlfix.

Hi,

you are right first var is $table. The $class is filled with '\Application\Modell\Myclassname' correctly.

The error is
Call to a member function Myclassname() on a non-object

Because the string is not working here. I can not make the full application new now with namespaces ;(

Thank you
Al