php 5.2以后增加了匿名函數(shù)這個功能,但我在匿名函數(shù)遞歸時發(fā)現(xiàn)了問題<?php$test = NULL;$test = function ($a) use ($test) { echo $a; $a --; if ($a > 0) { return $test($a);
}
};$test(10);正如上面的代碼所示,我想在$test這個匿名函數(shù)里遞歸調(diào)用它自己,但是我發(fā)現(xiàn)在調(diào)用后會出現(xiàn)Fatal error: Function name must be a string in /Library/WebServer/Documents/test.php on line 9
- 2 回答
- 0 關注
- 113 瀏覽
添加回答
舉報
0/150
提交
取消