The difference between forward and redirect in Zend Framework

After looking around, I saw that what everyone said was not fun or straightforward. Let me quote an analogy someone on Stackoverflow made:

You are a hard-working developer. The phone on the desk rang. After answering the call, the person said that he wanted to find a salesperson to talk to. You said: The sales line is 020-12345678, and then hung up. This is redirect. In another case, you say, wait, I'll transfer it to you, and then transfer the call to a sales department. This is forward.

$this->_redirect($url);
$this->_redirect('/Read/novel/id/3');
$this->_redirect('http://www.oschina.net');
//这个redirect转了哪些参数,别人是不是一目了然?

If you use forward, you can jump between Module, Controller and Action, but you can't jump to someone else's website.

$this->_forward('action','controller','module',$param);
//转到www.ursite.com/Controller/action/$param

$this->_forward('novel','Read','default',array('id'=> $id,'mode'=> $mode));
//转到www.ursite.com/Read/novel/id/3/mode/fullverion,这个3和fullversion是变量

$this->_forward('poem','null','null',array('id'=> $id,'mode'=> $mode));
//这个forward,跳到别的网站去,如果在同一个Controller下另一个novel动作,可以节省流量,节省计算资源

In addition, after forward, the address displayed in the address bar remains unchanged.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325484360&siteId=291194637