(Yaf >=3.2.2)
Yaf_Request_Abstract::getQuery — 获取查询参数
从 $_GET 中获取变量。
name变量名。如果省略,则返回整个数组。
default如果未找到变量则要返回的值。
返回查询参数值,如果未设置则返回 default。
示例 #1 Yaf_Request_Abstract::getQuery() 示例
<?php
class SearchController extends Yaf_Controller_Abstract
{
public function indexAction()
{
// 假设请求为 /search?keyword=yaf&page=2
$keyword = $this->getRequest()->getQuery("keyword");
$page = (int) $this->getRequest()->getQuery("page", 1);
var_dump($keyword, $page);
}
}
?>以上示例的输出类似于:
string(3) "yaf" int(2)