Zend framework - send a message from the current a

2019-07-03 07:30发布

问题:

In Zend framework: how can I send a message from the current action to another action in Controller?

回答1:

This is a very simple example of using FlashMessenger, so you can use it on your code:

public function indexAction()
{
    $messages = $this->_helper->FlashMessenger->getMessages('actions');
    echo $messages[0];
}


public function redirectAction()
{
    $this->_helper->FlashMessenger->addMessage("Your message", 'actions');
    $this->_redirect('index/index');
}

If you point in browser at 'redirect' action, you should get indexAction with the message.