Result from $_SERVER['HTTP_REFERER'], when referer header is not sent to server

前端 未结 3 1983
独厮守ぢ
独厮守ぢ 2021-01-04 03:58

When the browser sends header info to the server, $_SERVER[\'HTTP_REFERER\'] should give us the previous page URL right?

What returns from $_SERVE

3条回答
  •  無奈伤痛
    2021-01-04 04:46

    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.

    As with all HTTP request headers, check for its existence when reading:

    $httpReferer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null;
    

提交回复
热议问题