2012-06-26 61 views
0

I M试图让Zend框架形式的请求的值从iphone应用程序中的表单获取值到获取方法中的PHP Web应用程序?

早些时候,我使用POST方法

但iPhone应用程序是给我的数据在get方法。

我如何可以使用它具有我使用像

$交=阵列后的值( 'ID'=> '2', '电子邮件'=> '4', )

我希望在提交表单时也可以在此表单值中获取值。

我使用它来获取提交值

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

,我想这让get方法值

$post = $this->getRequest(); 

我得到这个错误 无法使用的对象键入Zend_Controller_Request_Http作为数组在

这是完全错误信息

"Zend_Controller_Request_Http Object ([_paramSources:protected] => Array ([0] => _GET [1] => _POST) [_requestUri:protected] => /platinum-picks/p-picks/index/registration [_baseUrl:protected] => /platinum-picks/p-picks [_basePath:protected] => [_pathInfo:protected] => /index/registration [_params:protected] => Array ([controller] => index [action] => registration [module] => default) [_rawBody:protected] => [_aliases:protected] => Array () [_dispatched:protected] => 1 [_module:protected] => default [_moduleKey:protected] => module [_controller:protected] => index [_controllerKey:protected] => controller [_action:protected] => registration [_actionKey:protected] => action) Fatal error: Cannot use object of type Zend_Controller_Request_Http as array in D:\Program Files\Zend\Apache2\htdocs\platinum-picks\application\models\User.php on line 267"

回答

1

如果我理解正确的,你想要得到的值用GET方法传递并已与邮政值成功做了同样的。你需要在这种情况下做出的唯一改变是这样的:

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

成为

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

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

Retrieves a merged array of parameters, with precedence of userland params (see setParam()), $_GET, $_POST (i.e., values in the userland params will take precedence over all others).

所以请参考手册如果这可能是你的问题。

+0

ya谢谢ypu get params工作 – Rinzler

1

可以使用例如找到GET变量:

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

或者,对于特定的变量:

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

这也将搜索为POST值。要搜索GET只有瓦尔,使用方法:

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

非常感谢你 – Rinzler

相关问题