Top.location.hraddress of the top-level window
this.location.hraddress of the current window
#Test website: http: / / localhost / sangsir / manito. PHP? Id = 1
/ / get domain name or host address
echo$_ SERVER['HTTP_ Host ']; ා localhost
/ / get web address
echo$_ SERVER['PHP_ Self ']; # / sangsir / manito. PHP
/ / get the URL parameter
echo$_ SERVER["QUERY_ String "]; ා id = 1
/ / get the complete URL
echo 'http: / /'$_ SERVER['HTTP_ HOST'].$_ SERVER['REQUEST_ Uri ']; / / the first echo' http: / / '$_ SERVER['HTTP_ HOST'].$_ SERVER['PHP_ SELF'].'?'.$_ SERVER['QUERY_ String ']; / / the second one is http: / / localhost / sangsir / manito. PHP? Id = 1
/ / the full URL containing the port number
echo' http: / / '$_ SERVER['SERVER_ NAME'].':'.$_ SERVER["SERVER_ PORT"].$_ SERVER["REQUEST_ Uri "];
http: / / localhost: 80 / sangsir / manito. PHP? Id = 1
/ / take only the path
$url ='http: / / '$_ SERVER['SERVER_ NAME'].$_ SERVER["REQUEST_ URI"];
echo dirname($url);
#http://localhost/sangsir