【问题标题】:Getting $_GET to work with Codeigniter让 $_GET 与 Codeigniter 一起工作
【发布时间】:2010-07-24 20:19:04
【问题描述】:

我看过几个例子,但我似乎无法让它发挥作用。

配置.php:

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

图书馆:

class MY_Input extends CI_Input  
{  
    function _sanitize_globals()  
    {  
        $this->allow_get_array = TRUE;  
        parent::_sanitize_globals();  
    }  
}  

控制器:

$this->load->library('MY_Input');  
..................  

$sid=$this->input->get('sid',TRUE);  
$name=$this->input->get('name',TRUE);  
$campid=$this->input->get('campid',TRUE);  
$rate=$this->input->get('rate',TRUE);  
$status=$this->input->get('status',TRUE);  

这是网址:

www.mysite.com/memb/index/postback.php?campid=23552342&name=mcamp&rate=15&sid=42&status=1&ip=198152999000

发生的情况是,它只是进入我的主页,没有更新数据库,也没有进入我在控制器中添加的测试视图页面,只是为了查看是否会加载视图。

编辑:现在看来,如果我尝试加载其他视图,我总是以主视图结束...

【问题讨论】:

    标签: php codeigniter get


    【解决方案1】:

    把它放在你的控制器中

    parse_str($_SERVER['QUERY_STRING'],$_GET);
    

    然后你可以像平常一样使用你的 $_GET 变量......即。回声 $_GET['var']

    【讨论】:

      【解决方案2】:

      我认为你需要做的是打开 application/config/config.php 文件,然后:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2023-03-18
        • 2012-07-23
        • 2016-12-13
        • 2016-10-06
        • 2011-11-30
        • 2014-02-19
        • 2011-09-03
        相关资源
        最近更新 更多