2017-04-19 58 views

回答

0

您只能使用use关键字来继承匿名函数(闭包)中的变量。这与声明的返回类型无关。

http://php.net/manual/en/functions.anonymous.php

在此澄清一点就是一个例子:

$a = 1; 
$func = function() use ($a) { 
    return $a + 1; 
} 
// Call the closure that has captured $a 
$func(); 
+0

啊......我明白了。命名函数只是函数。他们不是一流的citatents像匿名功能? JS中不是这样,所以我感到困惑。 – vladamx

+0

是的,当涉及到这样的事情时,php是陈旧的;) –

+0

PHP中没有头等公民:P –

相关问题