【问题标题】:How to get the redirect url from the redirect functions in Zend如何从 Zend 中的重定向函数中获取重定向 url
【发布时间】:2014-05-06 04:54:13
【问题描述】:

我在我的代码中使用了不同的重定向函数,比如

return $this->_helper->redirector->gotoUrl('profile/linto/', array('prependBase' => false));

return $this->_helper->redirector->gotoRoute($session->params, $session->route, $session->reset);

return $this->_redirect($uri, array('prependBase' => false));

所有这些情况,正确的重定向正在发生。

但我需要的是,我需要获取这些函数生成的重定向 url,而不是重定向。

有人知道吗?

【问题讨论】:

    标签: php zend-framework socialengine


    【解决方案1】:

    您可以使用 URL 助手:

    url($urlOptions, $name, $reset, $encode)
    

    例如。

    $this->view->url($session->params, $session->route, $session->reset)
    

    还要检查baseUrl() Helper

    例如。

    $url = $this->view->baseUrl().'profile/linto/';
    

    【讨论】:

      【解决方案2】:

      ZF2的建议

      您可以从控制器重定向:

      $this->redirect()->toRoute('route', array('action' => 'your-action-name'));
      

      从视图文件中你必须使用 url helper

      $this->url('route', array('action' => 'your-action-name'));
      

      【讨论】:

        猜你喜欢
        • 2021-03-28
        • 2013-06-06
        • 2013-02-24
        • 1970-01-01
        • 2011-03-22
        • 1970-01-01
        • 2016-12-11
        • 1970-01-01
        • 2018-05-02
        相关资源
        最近更新 更多