基于模块的php系统 [英] Module based php system
本文介绍了基于模块的php系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试制作一个基于模块的php系统.
I'm trying to make a module based php system.
每个模块都是一个类,该类实现模块接口并与php文件具有相同的名称.每个模块都位于名为Modules的目录中.
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??
}
推荐答案
$module = new $$module_name();
http://php.net/manual/en/language.variables. variable.php
这篇关于基于模块的php系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文