是否可以像在CodeIgniter中一样在ExpressionEngine中获取所有post变量? [英] Is it possible to get all post variables in ExpressionEngine, like you could in CodeIgniter?
问题描述
在CI中的控制器中,您可以通过执行以下操作来获取所有发布变量:
In a controller in CI you could get all post variables by doing something like this:
$data = $this->input->post();
在EE(由同一人根据CI构建)中,类似语法为:
In EE (built off of CI by the same people) the analogous syntax would be:
$data = $this->EE->input->post();
唯一的问题是,您得到的是布尔值false,而不是包含所有数据的数组.
The only issue is that instead of an array with all of the data, you get a boolean of false.
是否有某种方法可以使用ExpressionEngine而不是POST超全局变量来获取所有发布数据的数组?
Is there some way of getting an array of all post data, using ExpressionEngine rather than the POST superglobal?
谢谢.
推荐答案
好吧,在仍然利用EE的安全功能的同时,针对POST的所有元素在EE中获得类似于CI的结果的方法如下:>
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:
foreach($_POST as $key => $value){
$data[$key] = $this->EE->input->post($key);
}
由于您可以按名称访问POST变量,因此可以在$ _POST中循环访问它们,然后显式调用每个变量将产生所需的结果.
Since you can access POST vars by name, looping through them in $_POST, then explicitly calling each will yield the desired result.
这篇关于是否可以像在CodeIgniter中一样在ExpressionEngine中获取所有post变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!