php 获取帖子数据,Zend 框架
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3745865/
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
Get post data, Zend Framework
提问by Upvote
I want to fetch posted data. But I am using no form. The data is postet by a jquery script with method post
and I would like to fetch it.
我想获取发布的数据。但我没有使用任何表格。数据由带有方法的 jquery 脚本 postet post
,我想获取它。
I know how to fetch parameters
我知道如何获取参数
$id = $this->getRequest ()->getParam ( 'id', null );
and form values
和形式值
$message = $form->getValue ( 'message' );
however I want to access post data and not parameters or form values. Any ideas?
但是我想访问发布数据而不是参数或表单值。有任何想法吗?
回答by Upvote
Here is my solution;)
这是我的解决方案;)
$this->getRequest()->getPost('id', null);
回答by Richard Ayotte
Actually, this might be more of what you're looking for.
实际上,这可能是您正在寻找的更多内容。
$this->getRequest()->getRawBody();
https://framework.zend.com/manual/1.12/en/zend.controller.request.html
https://framework.zend.com/manual/1.12/en/zend.controller.request.html
回答by Erdal Mersinlioglu
Here is an other example:
这是另一个例子:
$this->getRequest()->getPost()->toArray()
回答by dhirendra
Try this:
尝试这个:
$request = $this->getRequest();
$request->getPost('field_name');