Python 有一个函数,我们可以在其中执行另一个 python 文件并从该文件中的 vars 中获取方法。下面是示例粗略代码来解释:=
file1.py
def method1():
print 'hello world'
file2.py
globals = file1.__dict__
execfile(file1.py, globals, locals);
# locals['method1'] has method up from file1.py. One can even execute it by doing locals['method1']();
我想在 PHP 中使用类似的方法,我可以在其中读取其他 PHP 文件并获取变量中的方法。这甚至可能吗