问题
Can I do something like this?
$arrayFn[1] = function fnName(){
echo "test";
}
$arrayFn[1];
回答1:
Anonymous functions cannot have a name:
$arrayFn[1] = function (){
echo "test";
};
$arrayFn[1](); // run it!
回答2:
$arrayFn[1] = function (){
echo "test";
};
$arrayFn[1]();
来源:https://stackoverflow.com/questions/22443213/store-function-inside-an-array