In PHP, the $ _ SERVER variable sorts out the current url :. $ _ SERVER [HTTP_HOST]. $ _ SERVER [PHP_SELF]; $ _ SERVER variable summary $ _ SERVER [QUERY_STRING] query string. $ _ SERVER [DOCUMENT_ROOT] $ _ SERVER variable sorting in PHP currently running the script
Current url:
'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
$ _ SERVER variable summary
$ _ SERVER ['query _ string'] // query string. $ _ SERVER ['document _ root'] // ROOT directory of the DOCUMENT where the script is currently running. Defined in the server configuration file. $ _ SERVER ['path _ TRANSLATED '] // The basic PATH of the file system where the current script is located (not the root directory of the document. $ _ SERVER ['php _ SELF '] // file name of the script being executed, which is related to document root. $ _ SERVER ['argv'] // parameters passed to the script. $ _ SERVER ['argc '] // contains the number of command line parameters passed to the program (if running in command line mode ). $ _ SERVER ['http _ ACCEPT '] // Accept of the current request: content in the header. $ _ SERVER ['http _ ACCEPT_CHARSET '] // The Accept-Charset of the current request: content in the header. Example: "ISO-8859-1, *, UTF-8 ". $ _ SERVER ['http _ ACCEPT_ENCODING '] // The Accept-Encoding of the current request: the content of the header. For example, "gzip ". $ _ SERVER ['http _ ACCEPT_LANGUAGE '] // The Accept-Language of the current request: content in the header. For example, "en ". $ _ SERVER ['http _ connection'] // CONNECTION of the current request: content in the header. For example, "Keep-Alive ". $ _ SERVER ['http _ host'] // HOST of the current request: content in the header. $ _ SERVER ['http _ referer'] // URL of the previous page linked to the current page. $ _ SERVER ['http _ USER_AGENT '] // User_Agent of the current request: content in the header. $ _ SERVER ['https'] // if accessed through HTTPS, it is set to a non-empty value (on ), otherwise, the system returns off $ _ SERVER ['remote _ ADDR '] // The IP address of the user browsing the current page. $ _ SERVER ['remote _ host'] // the HOST name of the user browsing the current page. $ _ SERVER ['remote _ port'] // The PORT used by the user to connect to the SERVER. $ _ SERVER ['request _ URI '] // URI required to access this page. For example, "/index.html ". $ _ SERVER ['request _ method'] // The request method used to access the page. For example, "GET", "HEAD", "POST", and "PUT ". $ _ SERVER ['script _ name'] // path containing the current SCRIPT. This is useful when the page needs to point to itself. $ _ SERVER ['script _ filename'] // The absolute path name of the currently executed SCRIPT. $ _ SERVER ['server _ admin'] // administrator information $ _ SERVER ['server _ name'] // NAME of the SERVER host where the script is currently running. $ _ SERVER ['server _ SIGNATURE '] // a string containing the SERVER version and virtual host name. $ _ SERVER ['server _ soft'] // The string identified by the SERVER, which is provided in the header of the response request. $ _ SERVER ['server _ port'] // name and version of the communication PROTOCOL used by the SERVER on the $ _ SERVER ['server _ protocol'] // request page. For example, "HTTP/1.0 ". $ _ SERVER ['gateway _ interface'] // The CGI standard version used by the SERVER. For example, "CGI/1.1 ". $ _ SERVER ['php _ AUTH_USER '] // When PHP runs in the Apache module mode and is using the HTTP authentication function, this variable is the user name entered by the user. $ _ SERVER ['php _ AUTH_PW '] // When PHP runs in the Apache module mode and is using the HTTP authentication function, this variable is the password entered by the user. $ _ SERVER ['auth _ type'] // When PHP runs in the Apache module mode and is using the HTTP authentication function, this variable is the authentication TYPE.