Zend Framework: Get Referrer Page?

后端 未结 3 1784
不知归路
不知归路 2021-01-01 15:41

Is there any way in Zend Framework to grab the url of the page the user visited last?

I don\'t really want to use $_SERVER[\'HTTP_REFERRER\'].

相关标签:
3条回答
  • 2021-01-01 15:58

    MWOP has put a good post here showing you how to get HTML headers (including referer).

    http://zend-framework-community.634137.n4.nabble.com/Referer-td3007321.html

    // In an action method of a controller
    $request = $this->getRequest();
    $request->getHeader('referer');
    
    0 讨论(0)
  • 2021-01-01 16:14

    If you want to do it in Module.php?

    I have find a small solution

    $headers = new \Zend\Http\PhpEnvironment\Request;

    $headers->getServer('HTTP_REFERER')

    0 讨论(0)
  • 2021-01-01 16:24

    From a controller method:

    $this->getRequest()->getServer('HTTP_REFERER')
    

    basically the same as using $_SERVER, but without causing problems in unit testing.

    0 讨论(0)
提交回复
热议问题