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 7.4 中的新箭头函数,并且正在尝试创建一个递归箭头函数。有人知道这是否可能吗?
这是我的代码:
$factorial = fn($x) => $x === 1 ? 1 : $x * $factorial($x - 1);
我在这里得到一个未定义的变量。我假设内部$factorial变量还不存在?
$factorial
错误信息Notice: Undefined variable: factorial in test.php on line 10
Notice: Undefined variable: factorial in test.php on line 10