arrays - Joomla 3.1 getUserStateFromRequest,它会返回一个数组吗?

标签 arrays joomla return state

简短而有趣 - 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);

关于arrays - Joomla 3.1 getUserStateFromRequest,它会返回一个数组吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17579290/

相关文章:

c# - 如何在 C# 中创建一个由 char、int、int 组成的 bool 3D 数组

joomla - 在 Joomla 组件开发中使用多个 Controller

mysql - PHPmyadmin 和 Joomla 与图像字段

php - Joomla Form 插件是否可以创建一个表并将表单数据保存到该表中?

php - return true 不返回或我的 else 声明不起作用?

c - Netbean IDE 上字符串数组中的不兼容指针类型警告

c - 如何将文件的编号存储在整数数组中

java - 如何在新数组中存储匹配字符

python - 我应该在使用功能后返回吗?

c# - 如何通过正则表达式删除字符串中多余的回车和空格?