在 ZF 中将变量从一个操作传递到另一个操作的视图


Pass a variable from an action to another action's view in ZF

我想知道zend是否允许这件事,如果是,那么如何?

public xAction()
{
// code here
}
public yAction(){
 $this->_helper->viewRenderer('x');
// code here....
// $this->view->variable= $somedata;
}
**x.phtml**
<?php echo $this->variable; ?>

Zend允许渲染不同的视图脚本。你可以这样做:$this->_helper->viewRenderer('controller/action', null, true);
更多信息在这里(示例 #11)