$ count = 2;
$ amt = 4;
$ str = function($ count ,$ amt){
return“有”。 $ count。 “和”。 $ amt;
};
echo $ str。 “!”;
code> pre>
如何将匿名函数的返回值存储到变量中? 我知道整个函数本身都存储在$ str中,这就是为什么这不起作用,但有办法吗? p>
div>
$count = 2;
$amt = 4;
$str = function($count, $amt) {
return "There is ". $count . " and " . $amt;
};
echo $str . "!";
How do I store the return value from the anonymous function into a variable? I know that the entire function itself is being stored into $str which is why this doesn't work, but is there a way to?