动态调用方法/功能 [英] Dynamically invoke method / function
本文介绍了动态调用方法/功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设函数的名称由GET传递。
我们如何调用该方法?
编辑:call_user_func()诀窍?
Say the name of the function is passed by GET.
How can we invoke the method?
call_user_func() does the trick?
推荐答案
call_user_func()应该有效。
你总是可以使用 eval 功能。
我会对调用函数的想法发出一个巨大的警告信号变量通过get tho!
想象一下... page.php?func = unlink("〜/ *");
Dunno如果确切的语法实际上可能会有类似的东西。
call_user_func() should work.
You could always use the eval function.
I would put a huge warning sign on the idea of calling functions from a variable passed by get tho!
Just imagine... page.php?func=unlink("~/*");
Dunno if that exact syntax actually works but something similar probably does.
Heya,Markus。
考虑验证你的功能名称。
例如:
Heya, Markus.
Consider validating your function name.
E.g.:
展开 | 选择 | Wrap | 行号
我不是傻瓜伙计们;]
像MVC一样,该类通过url传递,方法如下。
I''m not stupid guys ;]
Like an MVC, the class is passed through the url and the method follows.
这篇关于动态调用方法/功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文