Javascript implementation:
top.location.href The address of the top window
this.location.href The address of the current window
PHP implementation:
//Get the domain name or host address
echo $_SERVER[‘HTTP_HOST’].”
”; #localhost
//Get the web page address
echo $_SERVER[‘PHP_SELF’].”
”; #/blog/testurl.php
//Get URL parameters
echo $_SERVER[“QUERY_STRING”].”
”; #id=5
//Get user agent
echo $_SERVER[‘HTTP_REFERER’].”
”;
//Get the complete url
echo 'http://' . [′ HTTPHOST ′]. _SERVER['REQUEST_URI'];
echo 'http://' . [′ HTTPH
OST ′]. _SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'];//Full url including port number
echo 'http://' . [′ SERVERNAM E′ ]
.
′:′ _SERVER[“SERVER_PORT”].$_SERVER ["REQUEST_URI"]; //Get only the pathurl=′ ht tp://′. _SERVER['SERVER_NAME']. S
E
RVER["R EQUE STURI”];ec hodi rname(url);').addClass('pre-numbering').hide();
$(this).addClass('has-numbering').parent().append($numbering);
for (i = 1; i ').text(i));
};
$numbering.fadeIn(1700);
});
});
The above introduces how to get the complete URL of the current page, including the url content. I hope it will be helpful to friends who are interested in PHP tutorials.
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn