在下面的例子中,是否可以从匿名函数内部访问“str”值?
$foo = array(
'str' => 'THIS IS A STRING',
'fn' => function () {
// is it possible from within here to access 'str'?
}
);
$foo['str']
吗?(我现在没有启用闭包的 PHP 版本可以测试) - zneak$foo
未定义。 - nicknisi$foo ['str']
,请参见我的解决方案: - Ian Campbell