-1

在搜索并尝试围绕该问题编写代码后,我将在这里提出问题。

我正在尝试按照 php 手册进行编码,并希望避免使用已弃用的函数。

这引发了我的问题,我如何通过 $_GET superglobal 获得 http_referer?

如果您想知道,我试图混淆一个 header() 以仅在会话当前处于活动状态且定义了 HTTP_referer 变量时才回复。

4

3 回答 3

7

$_SERVER弃用$HTTP_SERVER_VARS是。

于 2013-04-30T20:18:07.537 回答
0

$HTTP_SERVER_VARS is deprecated, $_SERVER is not!

$_SERVER is an array containing information such as headers, paths, and script locations. The entries in this array are created by the web server. There is no guarantee that every web server will provide any of these; servers may omit some, or provide others not listed here. That said, a large number of these variables are accounted for in the » CGI/1.1 specification, so you should be able to expect those.

$HTTP_SERVER_VARS contains the same initial information, but is not a superglobal. (Note that $HTTP_SERVER_VARS and $_SERVER are different variables and that PHP handles them as such)

于 2013-04-30T21:02:26.603 回答
0

根据http://php.net/manual/en/reserved.variables.server.php $_SERVER 没有被弃用,只有 $HTTP_SERVER_VARS 是。也就是说,您可以自由使用 $_SERVER['HTTP_REFERER']

于 2013-04-30T20:20:06.930 回答