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 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?