dongzun9958 2011-10-06 14:55
浏览 36
已采纳

如何从zend中的_forward()助手获取数据?

I am using _forward() helper to pass an array from one to another action.. but i don't know how can i access this array in my receiving action.. here is the _forward() helper i am using

$this->_forward('action', 'controller', 'null', $Myarray);

is this correct and how can i access this $Myarray in my another action of same controller

  • 写回答

1条回答 默认 最新

  • dsghpgmay31938863 2011-10-06 20:19
    关注

    If you were to _forward() a request to another controller/action, you would access the params you passed by calling $this->getRequest()->getParam('param'); from the controller action that was the handler for the forward.

    Example:

    // in IndexController testAction
    $myarray = array(
        'param1' => 'value1',
        'param2' => 'value2'
    );
    $this->_forward('forward-test', 'Test', null, $myarray);
    
    // In TestController forwardTestAction
    $value1 = $this->getRequest()->getParam('param1', '');
    $value2 = $this->getRequest()->getParam('param2', '');
    

    If $Myarray is not an array with key-value pairs or you want to access it from a single parameter, you would want to set the 4th parameter of _forward() to something like array('myarrayparam' => $Myarray) and then receive it with $this->getRequest()->getParam('myarrayparam', array());

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集