开发者

Module based php system

开发者 https://www.devze.com 2022-12-22 11:44 出处:网络
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 Modu

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 ge开发者_StackOverflowt 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??
 }


$module = new $$module_name();

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

0

精彩评论

暂无评论...
验证码 换一张
取 消