【问题标题】:is it possible to foreach $this->input->post(); in codeigniter?是否可以 foreach $this->input->post();在代码点火器中?
【发布时间】:2011-02-28 02:31:13
【问题描述】:

我正在为 CI 编写一个库,并且我有一个方法可以调用来收集所有可能的 post 变量。我想以某种方式利用 codeigniter 输入类中内置的 xss 和安全类。

这可能吗?

这是不使用任何CI输入类的工作方法。


private function parse_options()
{  
    foreach($_POST as $key => $val)  
    {  
        $options[$key] = $val;  
    }  

    return $options;      
}

【问题讨论】:

    标签: php codeigniter post


    【解决方案1】:

    那为什么不呢:

    private function parse_options()
    {  
        foreach($_POST as $key => $val)  
        {  
            $options[$key] = $this->input->post($key);  
        }  
    
        return $options;      
    }
    

    【讨论】:

      【解决方案2】:

      大约 8 年后..

      文档 (https://www.codeigniter.com/user_guide/libraries/input.html) 是这样说的:

      $this->input->post(NULL, TRUE); // returns all POST items with XSS filter
      $this->input->post(NULL, FALSE); // returns all POST items without XSS filter
      

      尝试仅以 ci 方式而不绕过 ci 的原因是为了保持统一。可能。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-07-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-03-05
        相关资源
        最近更新 更多