CodeIgniter current_url不显示查询字符串 [英] CodeIgniter current_url doesn't show query strings

查看:149
本文介绍了CodeIgniter current_url不显示查询字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我的应用程序使用查询字符串,如www.domain.com/add?url=http ://www.google.com



,但current_url()会传回「ww.domain.com/add」。没有查询字符串的网址。



我已经检查过帮助文件,current_url似乎只是将uri段附加到配置中的site_url集。

  function current_url()
{
$ CI =& get_instance();
return $ CI-> config-> site_url($ CI-> uri-> uri_string());
}

任何人都知道我可以抓取查询字符串来追加它们,抓取整个网址。

解决方案

创建MY_url_helper:

  function current_url()
{
$ CI =& get_instance();

$ url = $ CI-> config-> site_url($ CI-> uri-> uri_string());
return $ _SERVER ['QUERY_STRING']? $ url。'?'。$ _ SERVER ['QUERY_STRING']:$ url;
}


Hi I'm trying to store my current url in a session variable.

My app uses query strings like www.domain.com/add?url=http://www.google.com

but current_url() returns 'ww.domain.com/add'. The url without the query strings.

I've checked the helper file and current_url seems to just append the uri segments to the site_url set in the config.

    function current_url()
{
    $CI =& get_instance();
    return $CI->config->site_url($CI->uri->uri_string());
}

anyone know how I can grab the query strings to append them, or even just grab the whole url.

解决方案

Create a MY_url_helper:

function current_url()
{
    $CI =& get_instance();

    $url = $CI->config->site_url($CI->uri->uri_string());
    return $_SERVER['QUERY_STRING'] ? $url.'?'.$_SERVER['QUERY_STRING'] : $url;
}

这篇关于CodeIgniter current_url不显示查询字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆