如何在没有PATH格式的YII中获取查询字符串值?

1 php yii

我有以下网址,

www.example.com/index.php?r=recommend/create&id=184?
title=Ruins%20of%20Mahabalipuram
&url=http://localhost/index.php/mediadetail/index/184
Run Code Online (Sandbox Code Playgroud)

我需要获取标题和url,它们是查询字符串参数.

有没有人在Yii中获取查询字符串中的值?

ipp*_*ppi 5

CHttpRequest中还有getParam()方法.

Yii::app()->request->getParam('title')
Run Code Online (Sandbox Code Playgroud)

我发现它是一个有价值的快捷方式,因为它检查$ _POST和$ _GET并优先使用$ _GET,因此您可以使用它来覆盖地址URL中的post变量.它还执行空检查,您可以在第二个参数中提供默认值.

缺点是你不能将它用于数组,也许它有点冗长(与$ _GET ['title']相比).