2
可能重复:
Is it possible to access outer local variable in PHP?
PHP closure scope problem如何访问声明为变量的函数内部的变量?
鉴于这种PHP函数:
function get_deals_by_type($records, $type) {
$available = function($record) {
if($record->mobile_type == $type) return $record;
};
return array_filter($records, $available);
}
...我怎样才能访问传递$type
功能的内申报在$available
?如现在所示,$type
对于array_filter
返回NULL
,而不管传递给get_deals_by_type()
的值是什么。
是的!正是我在找什么。谢谢! – neezer 2011-12-17 00:32:09