简短而甜蜜 - 可以getUserStateFromRequest
返回一个数组吗?API 文档似乎不完整?
非常感谢!
如果 Joomla 文档仍然非常有限,但在 Joomla 2.5 中查看 JApplication:: 的来源
public function getUserStateFromRequest($key, $request, $default = null, $type = 'none')
{
$cur_state = $this->getUserState($key, $default);
$new_state = JRequest::getVar($request, null, 'default', $type);
// Save the new value only if it was set in this request.
if ($new_state !== null)
{
$this->setUserState($key, $new_state);
}
else
{
$new_state = $cur_state;
}
return $new_state;
}
答案是肯定的,如果你设置它可以
JRequest::setVar('var1', array(1,2,3), 'default');
JFactory::getApplication->setUserState('var1', array(123));
或者只是将它与请求一起传递
$_GET['var1'] = array(1,2,3);
$_POST['var1'] = array(1,2,3);