开发者

how do I assign page referrer to a php variable

开发者 https://www.devze.com 2022-12-21 23:00 出处:网络
I am using javascript开发者_Python百科 to get the referring page (document.referrer) which works fine and I can add this value to a div no problem.

I am using javascript开发者_Python百科 to get the referring page (document.referrer) which works fine and I can add this value to a div no problem.

How do I assign this value to a PHP variable in order to do some other things with it?

Ideally, something like:

$myphpvariable  = document.referrer;


what about

$myphpvariable = $_SERVER['HTTP_REFERRER'];

?


You can use

$_SERVER['HTTP_REFERER']

and since this is PHP this happens on the server side.

More info: $_SERVER in PHP

As a side note REFERER is sent by the user agent as part of the HTTP request - do not rely on it to be truthful!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号