php 是否可以像在 CodeIgniter 中一样在 ExpressionEngine 中获取所有后期变量?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11128198/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 23:48:31  来源:igfitidea点击:

Is it possible to get all post variables in ExpressionEngine, like you could in CodeIgniter?

phpcodeigniterpostexpressionengine

提问by Mike_K

In a controller in CI you could get all post variables by doing something like this:

在 CI 中的控制器中,您可以通过执行以下操作来获取所有后期变量:

$data = $this->input->post();

In EE (built off of CI by the same people) the analogous syntax would be:

在 EE(由相同的人从 CI 构建)中,类似的语法是:

$data = $this->EE->input->post();

The only issue is that instead of an array with all of the data, you get a boolean of false.

唯一的问题是,您得到的不是包含所有数据的数组,而是布尔值 false。

Is there some way of getting an array of all post data, using ExpressionEngine rather than the POST superglobal?

有没有办法使用 ExpressionEngine 而不是 POST superglobal 来获取所有发布数据的数组?

Thanks.

谢谢。

回答by Jewel

Try native

尝试原生

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

Ref: https://www.codeigniter.com/user_guide/libraries/input.html

参考:https: //www.codeigniter.com/user_guide/libraries/input.html

回答by Mike_K

Ok, the way to get results similar to CI within EE for all elements of a POST, while still leveraging the security features of EE is the following:

好的,在 EE 中为 POST 的所有元素获得类似于 CI 的结果,同时仍然利用 EE 的安全功能的方法如下:

foreach($_POST as $key => $value){
     $data[$key] = $this->EE->input->post($key);
}

Since you can access POST vars by name, looping through them in $_POST, then explicitly calling each will yield the desired result.

由于您可以按名称访问 POST 变量,在 $_POST 中循环它们,然后显式调用每个变量将产生所需的结果。