Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
那么递归匿名函数是否存在于自然界中?特别是在 PHP...
$f = function ($node) { foreach ($node->operands as $operand) { $f($operand); // o_0 } }
是的,但这并不明显:
$f = function($node) use (&$f) { var_dump($f); }; $f(1);
输出:
object(Closure)#1 (2) { ["static"]=> array(1) { ["f"]=> *RECURSION* } ["parameter"]=> array(1) { ["$node"]=> string(10) "<required>" } }