我尝试使用 this解决方案,但它对我不起作用。我的 $this
没有 getRequest()
方法,Zend\Http\Request
也根本没有。
我试过类似的东西
$request = new \Zend\Http\Request();
$http_referer = $request->getHeader('referer');
但它只返回 boolean false
。我缺少什么?
最佳答案
知道了,我用错类了。我们需要使用 \Zend\Http\PhpEnvironment\Request()
这个是正确的:
$request = new \Zend\Http\PhpEnvironment\Request();
$http_referer = $request->getServer('HTTP_REFERER');
关于php - 如何在 Zend Framework 中获取 HTTP_REFERER,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36426014/