doumibi6899 2013-08-01 11:05
浏览 15
已采纳

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

I am having following url,

www.example.com/index.php?r=recommend/create&id=184?
title=Ruins%20of%20Mahabalipuram
&url=http://localhost/index.php/mediadetail/index/184

I need to get title and url which are query string parameters.

Has anyone worked on getting values in query string in Yii?

  • 写回答

3条回答 默认 最新

  • dsw8292301 2013-08-02 02:48
    关注

    There is also the getParam() method in CHttpRequest.

    Yii::app()->request->getParam('title')
    

    I've found it a valuable shortcut, since it checks both $_POST and $_GET and gives priority to $_GET, so you can use it to override post variables in the address URL. It also performs null checks and you can provide a default value in the second parameter.

    The drawbacks are that you can't use it for arrays and maybe it's a little bit verbose (compared to $_GET['title']).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 关于#python#的问题:自动化测试