dttl3933
2017-05-04 02:16
浏览 163
已采纳

如何在CodeIgniter中获取其get请求的当前url?

This is my current url:

http://myhost/main?my_id=1,3

How can I get this url in CodeIgniter, and is it included with 'my_id'?

NOTE:

I mean when echo $url, it shows like this: http://myhost/main?my_id=1,3

图片转代码服务由CSDN问答提供 功能建议

这是我当前的网址:

  http://  myhost / main?my_id = 1,3 
   
 
 

如何在CodeIgniter中获取此url,是否包含在'my_id'中?

注意:

我的意思是当 echo $ url 时,它显示如下: http:/ / myhost / main?my_id = 1,3

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongpan8928 2017-05-04 02:33
    已采纳

    simple get like this

    echo $this->input->get('my_id');
    

    Load the URL helper To get current url

    $currentURL = current_url(); //http://myhost/main
    
    $params   = $_SERVER['QUERY_STRING']; //my_id=1,3
    
    $fullURL = $currentURL . '?' . $params; 
    
    echo $fullURL;   //http://myhost/main?my_id=1,3
    

    Note : make sure that query string is not empty and then concatenate .

    打赏 评论

相关推荐 更多相似问题