6

我不确定为什么这不起作用。我在配置文件中有 allow_get_array = TRUE 。这就是我想要做的..

这是用户将从他们的电子邮件中单击的链接

http://www.site.com/confirm?code=f8c53b1578f7c05471d087f18b343af0c3a638

confirm.php 控制器:

$code = $this->input->get('code');

也试过

$code = $this->input->get('code', TRUE);

有任何想法吗?

4

4 回答 4

8

在您的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 类

于 2012-12-26T22:17:39.123 回答
5

用这个:

$code = isset($_REQUEST['code']) ? $_REQUEST['code'] : NULL;

编辑:

在 PHP >=7.0 中,您可以这样做:

$code = $_REQUEST['code'] ?? NULL;
于 2014-08-02T20:45:25.773 回答
4

我这样做了,它无需更改配置文件即可工作:

//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']; 
于 2012-12-27T01:14:35.603 回答
0

你能试试吗

http://www.site.com/confirm/?code=f8c53b1578f7c05471d087f18b343af0c3a638

代替

http://www.site.com/confirm?code=f8c53b1578f7c05471d087f18b343af0c3a638

没有任何配置,否则请编辑

于 2012-12-26T23:08:23.900 回答