[英]How to receive post/get request in codeigniter
Im using我正在使用
$this->input->post('name') ;
to get a request posted to my url.Instead of post I need to access get as well.将请求发布到我的 url.In 而不是 post 我也需要访问 get 。
Like in normal php its ,$_REQUEST is used.But what about in codeigniter standards,how is it possible?就像在普通的 php 中一样,它使用了 $_REQUEST。但是在 codeigniter 标准中,这怎么可能呢?
It's outlined in the docs here:http://ellislab.com/codeigniter/user-guide/libraries/input.html它在此处的文档中进行了概述:http ://ellislab.com/codeigniter/user-guide/libraries/input.html
To grab data from the get
you can use要从
get
获取数据,您可以使用
$this->input->get('some_data', TRUE);
That looks for some_data
in the query string, and will run is through XSS filtering to clean it from possible hack attempts在查询字符串中查找
some_data
,并将通过 XSS 过滤运行以清除可能的黑客尝试
There's also a handy method to check both at the same time:还有一个方便的方法可以同时检查两者:
$this->input->get_post('some_data', TRUE);
"This function will search through both the post and get streams for data, looking first in post, and then in get"
“此功能将在 post 和 get 流中搜索数据,首先在 post 中查找,然后在 get 中查找”
Try this: 试试这个:
http://ellislab.com/codeigniter/user-guide/libraries/input.html http://ellislab.com/codeigniter/user-guide/libraries/input.html
You will get all methods to fetch data. 您将获得所有获取数据的方法。
Try this if you want to post request from server如果您想从服务器发布请求,请尝试此操作
if ($this->input->server('REQUEST_METHOD') == 'POST'){}
if ($this->input->server('REQUEST_METHOD') == 'GET'){}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.