从 $_SERVER['HTTP_REFERER'] 获取参数

发布于 2024-10-02 03:57:48 字数 345 浏览 1 评论 0原文

我想以与从请求中获取值相同/相似的方式从 http_referer 获取值:

$this->_getParam('order', 0);

我想我会尝试这样的事情:

$lastrequest = new Zend_Controller_Request_Http($_SERVER['HTTP_REFERER']);
$lastorder = $lastrequest->getParam('order', 0);

但这不起作用。没有参数。 getParams 返回一个空字符串。我缺少什么?有更好的方法吗?

谢谢!

I want to get a value from the http_referer in the same/similar way you'd get it from a request:

$this->_getParam('order', 0);

I thought I'd try something like this:

$lastrequest = new Zend_Controller_Request_Http($_SERVER['HTTP_REFERER']);
$lastorder = $lastrequest->getParam('order', 0);

But that doesn't work. There are no parameters. getParams returns an empty string. What am I missing? Is there a better way to do this?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

岁月苍老的讽刺 2024-10-09 03:57:48

这通常是一个坏主意。

除了 Justin 指出的之外,通过这些更容易直接将值添加到新页面,而不是尝试从引用者中解析它们。

This is generally a bad idea.

On top of what Justin pointed out, it's easier to just pass those values on to the new page directly rather than trying to parse them from the referrer.

稚气少女 2024-10-09 03:57:48

来自 HTTP_REFERER 的 PHP 文档

将用户代理引导至当前页面的页面地址(如果有)。这是由用户代理设置的。并非所有用户代理都会设置此项,有些用户代理提供了修改 HTTP_REFERER 的功能。简而言之,它确实不能被信任。

所以请记住这个参数甚至可能不是由浏览器设置的......

From the PHP docs for HTTP_REFERER:

The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.

So keep in mind this parameter may not even be set by the browser...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文