tags:

views:

49

answers:

1

Hello!

I'm trying to make a module based php system.

Each module is a class which implements a module interface and got the same name as the php file. Each module is located inside a directory called Modules.

I can list every module in the directory, but how do i get an instance of them? Is it even possible?

A little pseudo-code to make it easier to understand:

    foreach(scandir($module_dir) as $file){
        include $file
        $module = new $file // How can i make this work??
 }
+4  A: 
$module = new $$module_name();

http://php.net/manual/en/language.variables.variable.php

Infinity
totally missed that one, THANKS!
shuwo