从 $_SERVER['HTTP_REFERER'] 获取参数
我想以与从请求中获取值相同/相似的方式从 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这通常是一个坏主意。
除了 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.
来自 HTTP_REFERER 的 PHP 文档:
所以请记住这个参数甚至可能不是由浏览器设置的......
From the PHP docs for HTTP_REFERER:
So keep in mind this parameter may not even be set by the browser...