缺少$

编程入门 行业动态 更新时间:2024-10-27 14:28:06
缺少$ _SERVER ['HTTP_REFERER']($_SERVER['HTTP_REFERER'] missing)

我想在我的网站中使用$_SERVER['HTTP_REFERER'] ,但我得到以下内容:

Notice: Undefined index: HTTP_REFERER

我曾尝试打印$_SERVER 。 这输出以下内容:

Array ( [HTTP_HOST] => 192.168.1.10 [HTTP_USER_AGENT] => Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:15.0) Gecko/20100101 Firefox/15.0 [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 [HTTP_ACCEPT_LANGUAGE] => en-us,en;q=0.5 [HTTP_ACCEPT_ENCODING] => gzip, deflate [HTTP_CONNECTION] => keep-alive [PATH] => /sbin:/usr/sbin:/bin:/usr/bin [SERVER_SIGNATURE] => Apache/2.2.3 (CentOS) Server at 192.168.1.10 Port 80 [SERVER_SOFTWARE] => Apache/2.2.3 (CentOS) [SERVER_NAME] => 192.168.1.10 [SERVER_ADDR] => 192.168.1.10 [SERVER_PORT] => 80 [REMOTE_ADDR] => 192.168.1.77 [DOCUMENT_ROOT] => /var/www/html [SERVER_ADMIN] => root@localhost [SCRIPT_FILENAME] => /var/www/html/sandeep/test/hash.php [REMOTE_PORT] => 53851 [GATEWAY_INTERFACE] => CGI/1.1 [SERVER_PROTOCOL] => HTTP/1.1 [REQUEST_METHOD] => GET [QUERY_STRING] => [REQUEST_URI] => /sandeep/test/hash.php [SCRIPT_NAME] => /sandeep/test/hash.php [PHP_SELF] => /sandeep/test/hash.php [REQUEST_TIME] => 1347365919 )

任何人都可以帮助我找到HTTP_REFERER或建议替代HTTP_REFERER ?

I want to use $_SERVER['HTTP_REFERER'] in my site but i get the following:

Notice: Undefined index: HTTP_REFERER

I have tried printing $_SERVER. This outputs the following:

Array ( [HTTP_HOST] => 192.168.1.10 [HTTP_USER_AGENT] => Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:15.0) Gecko/20100101 Firefox/15.0 [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 [HTTP_ACCEPT_LANGUAGE] => en-us,en;q=0.5 [HTTP_ACCEPT_ENCODING] => gzip, deflate [HTTP_CONNECTION] => keep-alive [PATH] => /sbin:/usr/sbin:/bin:/usr/bin [SERVER_SIGNATURE] => Apache/2.2.3 (CentOS) Server at 192.168.1.10 Port 80 [SERVER_SOFTWARE] => Apache/2.2.3 (CentOS) [SERVER_NAME] => 192.168.1.10 [SERVER_ADDR] => 192.168.1.10 [SERVER_PORT] => 80 [REMOTE_ADDR] => 192.168.1.77 [DOCUMENT_ROOT] => /var/www/html [SERVER_ADMIN] => root@localhost [SCRIPT_FILENAME] => /var/www/html/sandeep/test/hash.php [REMOTE_PORT] => 53851 [GATEWAY_INTERFACE] => CGI/1.1 [SERVER_PROTOCOL] => HTTP/1.1 [REQUEST_METHOD] => GET [QUERY_STRING] => [REQUEST_URI] => /sandeep/test/hash.php [SCRIPT_NAME] => /sandeep/test/hash.php [PHP_SELF] => /sandeep/test/hash.php [REQUEST_TIME] => 1347365919 )

Can anyone help me to find HTTP_REFERER or suggest an alternative to HTTP_REFERER?

最满意答案

从文档:

将用户代理引用到当前页面的页面地址(如果有的话)。 这由用户代理设置。 并非所有的用户代理都会设置它,有些提供了将HTTP_REFERER修改为功能的功能。 总之,它不能真正被信任。

http://php.net/manual/en/reserved.variables.server.php

From the documentation:

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.

http://php.net/manual/en/reserved.variables.server.php

更多推荐

本文发布于:2023-08-02 05:18:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1370050.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!