来自$ _SERVER ['HTTP_REFERER']的结果,当referer标头未发送到服务器时 [英] Result from $_SERVER['HTTP_REFERER'], when referer header is not sent to server
问题描述
当浏览器向服务器发送标题信息时, $ _ SERVER ['HTTP_REFERER']
应该为我们提供上一页网址吗?
When the browser sends header info to the server, $_SERVER['HTTP_REFERER']
should give us the previous page URL right?
当头信息没有发送到服务器时,从 $ _ SERVER ['HTTP_REFERER']
返回什么?空字符串?假?空值?或者??
What returns from $_SERVER['HTTP_REFERER']
, when header info is not sent to server? empty string? false? null? or... ?
推荐答案
如果没有发送HTTP referer请求标头,那么 $ _ SERVER [ 'HTTP_REFERER']
可能未设置,尽管它可能是一个空字符串。在这种情况下是否设置可能取决于服务器。
If the HTTP referer request header is not sent then the $_SERVER['HTTP_REFERER']
is probably not set, although it could be an empty string. Whether it is set or not in this case could depend on the server.
与所有HTTP请求标头一样,在阅读时检查它是否存在:
As with all HTTP request headers, check for its existence when reading:
$httpReferer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null;
这篇关于来自$ _SERVER ['HTTP_REFERER']的结果,当referer标头未发送到服务器时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!