【发布时间】:2017-09-12 08:57:44
【问题描述】:
我有一个这样的数组:
$currentSelection = array('category' => $request->category, 'location' => $request->location);
当我将这个发送到这样的视图时:
return view('index', compact('currentSelection'));
我收到这条消息:
未定义的变量 currentSelection
如何使用 compact() 正确发送数组?
【问题讨论】:
-
您确定
$currentSelection是在某个范围内定义的吗?compactwill not issue warnings if it doesn't exist,很可能你的底层view函数正在窒息。 -
@Mark 你是对的,这确实是一个范围问题。我该如何结束这个问题?
-
我已经标记了它。很高兴你解决了你的问题!