PHP:匿名函数可以返回吗?
发布时间:2020-12-13 14:07:53 所属栏目:PHP教程 来源:网络整理
导读:参见英文答案 How to get the factorial value of each number in an array?1个 在一些PHP测验中,我得到了以下任务 – 我必须在以下内容中返回true: function foo($x){ return $x === $x();}foo(__________ALLOWED_INPUT____________); 现在我的想法是传递
参见英文答案 >
How to get the factorial value of each number in an array?1个
在一些PHP测验中,我得到了以下任务 – 我必须在以下内容中返回true: function foo($x) { return $x === $x(); } foo(__________ALLOWED_INPUT____________); 现在我的想法是传递一个自动返回的匿名函数: foo(function() { return $this_function; }) 但是我还没有找到办法做到这一点.有可能吗? PS:尼斯游戏(https://returntrue.win/?level=6).
您可以创建一个匿名函数,该函数返回对自身的引用:
foo($x=function()use(&$x){return$x;}) http://sandbox.onlinephpfunctions.com/code/743f72c298e81e70f13dc0892894911adfb1b072 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |