如果我有一个名为 myFunctions 的数组,其中包含这样的 php 函数名称...
$myFunctions= array("functionA", "functionB", "functionC", "functionD",....."functionZ");
如何使用该数组调用所有这些函数?
最佳答案
您可以使用 variable functions
PHP supports the concept of variable functions. This means that if a variable name has parentheses appended to it, PHP will look for a function with the same name as whatever the variable evaluates to, and will attempt to execute it. Among other things, this can be used to implement callbacks, function tables, and so forth.
foreach($myFunctions as $func) {
$func();
}
关于php - 如何调用数组中的所有php函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25578714/