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

前端 未结 3 1995
独厮守ぢ
独厮守ぢ 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:56

    $_SERVER is a global array variable, and the referrer value is an element of the array with key HTTP_REFERER. If is no referrer header is sent by the browser, then the element is simply missing from the array. You can check whether an array has an element with array_key_exists; in this case:

    array_key_exists('HTTP_REFERER', $_SERVER)

提交回复
热议问题