【发布时间】:2011-08-16 14:37:58
【问题描述】:
在以下示例中,是否可以从匿名函数中访问“str”值?
$foo = array(
'str' => 'THIS IS A STRING',
'fn' => function () {
// is it possible from within here to access 'str'?
}
);
【问题讨论】:
-
不能直接访问
$foo['str']吗? (我现在没有要测试的启用闭包的 PHP 版本) -
不,
$foo未定义。 -
...它可以直接访问
$foo['str'],请看下面我的解决方案:
标签: php associative-array