php - 如何在 Zend Framework 中获取 HTTP_REFERER

标签 php http zend-framework http-referer referer

我尝试使用 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/

相关文章:

PHP 的 mysql 迁移到 mysqli 性能

php - Tumblr API V2 错误代码 429 : "Rate Limit Exceeded" You are being rate limited, 速度变慢。标题信息?

python - Selenium 不断返回 "Message: element not interactable: [object HTMLButtonElement] has no size and location"

php - 以特殊字符开头的路由 URL

php - Symfony2 形成部分绑定(bind)

php - 处理从表单输入到 SQL 的空值

c# - 我必须显式关闭异步 http 请求的 ResponseStream 吗?

php - 缓存呼应 CSS 代码的 PHP 页面

php - 使用 PHP Farm 激活 php 扩展的问题

php - 将 My Zend Framework 应用程序与 Wordpress 集成并进行一次登录