$ _GET在Codeigniter 2.1.3中不起作用 [英] $_GET does not work in Codeigniter 2.1.3

查看:161
本文介绍了$ _GET在Codeigniter 2.1.3中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从URI获取 ref 的值,看起来像这样 http:// localhost / project /?ref = 6
现在我知道 $ _ GET ['ref'] 将不能在codeigniter中工作。我尝试通过设置 $ config ['allow_get_array'] = TRUE; 启用它,但它不工作。

I want to get ref value from URI which looks like this http://localhost/project/?ref=6 Now I know that $_GET['ref'] will not work in codeigniter. I tried to enable it by setting $config['allow_get_array'] = TRUE; but it didn't work.

我读了一些关于使用 $ this-> input-> get('ref')但没有运气的地方。在使用它之前,我已经在config.php中加载了输入库。

I read on SO somewhere about using $this->input->get('ref') but no luck. Before using it I did loaded input library in config.php.


我想在模型中访问此值

Note: I want to access this value in model

在config.php中添加

Added in config.php

$config['uri_protocol'] = "PATH_INFO";
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-?';

并注释现有 $ config ['uri_protocol'] ='REQUEST_URI'; $ config ['permitted_uri_chars'] ='az 0-9〜%。:_ \ - ';

控制器代码是:

parse_str($_SERVER['QUERY_STRING'], $_GET);
        $ref = $this->security->xss_clean($_GET['ref']);
        log_message('info','>>>>>>>>>>>>>>>>>>enter email_invites method::'.$ref);

但是我还是没有得到任何值,我看不到我的任何日志消息。 / p>

But still I don't get any value and somehow I dont see any of my log messages.

推荐答案

此行将解析URL并填充 $ _ GET 数组URL参数:

This line will parse the URL and populate the $_GET array with the URL's parameters:

parse_str(substr(strrchr($_SERVER['REQUEST_URI'], "?"), 1), $_GET);

然后可以像访问数组一样访问它,例如:

It can then be accessed as you would normally access an array, for example:

$ref = $_GET['ref'];

您应设置 - application / config / config.php 如下:

You config - application/config/config.php - should be set as follows:

$config['uri_protocol'] = "PATH_INFO";

这篇关于$ _GET在Codeigniter 2.1.3中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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