要获取当前页面的完整地址我们要经过很多操作如http或https,php文件与路径,主机域名,查询参数最后就成了。
获取协议-http:url的协议,可以读出在$ _server ['server_protocol']变量。
- */
- echo $_server['server_protocol'];
-
-
-
- $protocol = strpos(strtolower($_server['server_protocol']),'https') === false ? 'http' : 'https';
-
-
- $host = $_server['http_host'];
-
-
-
- $script = $_server['script_name'];
-
-
- $params = $_server['query_string'];
-
-
- $uri = $_server['request_uri'];
-
- $protocol = strpos(strtolower($_server['server_protocol']),'https') === false ? 'http' : 'https';
- $host = $_server['http_host'];
- $script = $_server['script_name'];
- $params = $_server['query_string'];
- $currenturl = $protocol . '://' . $host . $script . '?' . $params;
- echo $currenturl;