只是好奇从查询字符串中获取变量的“Kohana”方法是什么?
我能想到的最好办法是用 Arr 类解析 $_GET 变量。有人有更好的方法吗?
// foo?a=1&b=2
function action_welcome()
{
echo('a = '.Arr::get($_GET, 'a', '0'));
echo('b = '.Arr::get($_GET, 'b', '0'));
}
最佳答案
我认为使用 Arr::get 太笼统了,使用专门为此设计的特定 Kohana 方法更实用
Request::current->query('variable')
或
$this->request->query('variable')
即使请求是内部的,您也可以将任何变量传递给它
关于php - 从 Kohana 3 中的查询字符串中获取值的正确方法是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3305286/