从 iPhone 应用程序中的表单获取值到 get 方法中的 php Web 应用程序


Get values from form in an iphone app to a php web appication in get method?

我试图在 zend 框架中获取表单的请求值

早些时候我正在使用 POST 方法

但是iPhone应用程序正在获取方法中向我发送数据。

我如何使用它,因为我使用了诸如

$post = 数组( 'id'=>'2', "电子邮件"=>"4", )

我也想在提交表单时在此表单值中获取值。

我用它来获取帖子值

      $post = $this->getRequest ()->getPost ();

我尝试了这个来获取方法值

    $post = $this->getRequest();

我收到此错误 不能使用 Zend_Controller_Request_Http 类型的对象作为数组

这是完整的错误消息

"Zend_Controller_Request_Http对象 ( [_paramSources:受保护] => 数组 ( [0] => _GET [1] => _POST ) [_requestUri:受保护] => /platinum-picks/p-picks/index/registration [_baseUrl:protected] => /白金选秀/P-挑秀 [_basePath:受保护] => [_pathInfo:受保护] =>/索引/注册 [_params:受保护] => 数组 ( [控制器] => 索引 [操作] => 注册 [模块] => 默认值 ) [_rawBody:受保护] => [_aliases:受保护] => 数组 ( ) [_dispatched:受保护] => 1 [_module:受保护] =>默认值 [_moduleKey:受保护] => 模块 [_controller:受保护] => 索引 [_controllerKey:受保护] => 控制器 [_action:受保护] => 注册 [_actionKey:受保护] => 操作 ) 致命错误:无法 在 D:''Program 中使用类型 Zend_Controller_Request_Http 的对象作为数组 Files''Zend''Apache2''htdocs''platinum-picks''application''models''User.php 在267行"

如果我理解正确,您希望使用 GET 方法获取传递的值,并且您已经成功地对 POST 值完成了相同的操作。在这种情况下,您需要进行的唯一更改是:

$post = $this->getRequest()->getPost ();

成为

$get = $this->getRequest()->getParams();

这也将从其他源返回参数:

检索合并的参数数组,优先于用户空间参数(请参阅 setParam())、$_GET、$_POST(即,用户空间参数中的值将优先于所有其他参数)。

因此,如果这对您来说可能是问题,请参阅手册。

您可以使用以下方法找到GET变量:

$this->getRequest()->getParams();

或者,对于特定变量:

$this->getRequest()->getParam('myVar');

这也将搜索POST值。要仅搜索 GET 变量,请使用:

$this->getRequest()->getQuery('myVar');