我不知道为什么这不起作用。我在配置文件中有allow_get_array = TRUE。这就是我想做的…
这是用户将从他们的电子邮件点击的链接
http://www.site.com/confirm?code=f8c53b1578f7c05471d087f18b343af0c3a638
confirm.php控制器:
$code = $this->input->get('code');
也试过
$code = $this->input->get('code', TRUE);
任何想法?
在您的config.php
中更改以下内容:
$config['uri_protocol'] = 'AUTO';
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_'-';
$config['enable_query_strings'] = FALSE;
:
$config['uri_protocol'] = 'REQUEST_URI';
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_'-?';
$config['enable_query_strings'] = TRUE;
您可以将URI更改为使用像http://www.site.com/confirm/code/f8c53b1578f7c05471d087f18b343af0c3a638
这样的段,而不是混淆查询字符串。要访问代码段,您将使用$this->uri->segment(3);
。我个人更喜欢这种方式,而不是使用查询字符串。参见URI类
使用
$code = isset($_REQUEST['code']) ? $_REQUEST['code'] : NULL;
编辑:在PHP>=7.0中,可以这样做:
$code = $_REQUEST['code'] ?? NULL;
我这样做了,它没有改变配置文件:
//put some vars back into $_GET.
parse_str(substr(strrchr($_SERVER['REQUEST_URI'], "?"), 1), $_GET);
// grab values as you would from an ordinary $_GET superglobal array associative index.
$code = $_GET['code'];
你能试一下吗
http://www.site.com/confirm/?code=f8c53b1578f7c05471d087f18b343af0c3a638
代替
http://www.site.com/confirm?code=f8c53b1578f7c05471d087f18b343af0c3a638
没有任何配置或其他编辑