如前所述,当没有支持(真的,没有)$config['enable_query_strings']
时,这是 Codeigniter 中的一种“遗留”设置。$_GET
http://codeigniter.com/user_guide/general/urls.html
启用查询字符串
在某些情况下,您可能更喜欢使用查询字符串 URL:
index.php?c=products&m=view&id=345
c
=== 您的控制器名称
m
=== 您的方法名称
其余的是方法参数。这是一个非常具有误导性的描述,并且在 URL 文档的其余部分中根本没有提及其他设置或查询字符串。我从来没有听说过有人真正使用它。CI$config['allow_get_array']= TRUE;
默认自带,这就是你想要的。
您可以修改current_url()
查询字符串支持的函数,只需创建application/helpers/MY_url_helper.php
并使用它:
function current_url($query_string = FALSE)
{
$CI =& get_instance();
$current_url = $CI->config->site_url($CI->uri->uri_string());
// BEGIN MODIFICATION
if ($query_string === TRUE)
{
// Use your preferred method of fetching the query string
$current_url .= '?'.http_build_query($_GET);
}
// END MODIFICATION
return $current_url;
}
然后像current_url(TRUE)
包含查询字符串一样调用它。