gpt4 book ai didi

php - 从 Kohana 3 中的查询字符串中获取值的正确方法是什么

转载 作者:可可西里 更新时间:2023-11-01 13:40:47 26 4
gpt4 key购买 nike

只是好奇从查询字符串中获取变量的“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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com