1<?php
2$uri = $_SERVER['REQUEST_URI'];
3echo $uri; // Outputs: URI
4
5$protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
6$url = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
7echo $url; // Outputs: Full URL
8
9$query = $_SERVER['QUERY_STRING'];
10echo $query; // Outputs: Query String
11?>
1<?php
2 if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on')
3 $url = "https://";
4 else
5 $url = "http://";
6 // Append the host(domain name, ip) to the URL.
7 $url.= $_SERVER['HTTP_HOST'];
8
9 // Append the requested resource location to the URL
10 $url.= $_SERVER['REQUEST_URI'];
11
12 echo $url;
13 ?>
1<?php
2 if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on')
3 $url = "https://";
4 else
5 $url = "http://";
6 // Append the host(domain name, ip) to the URL.
7 $url.= $_SERVER['HTTP_HOST'];
8
9 // Append the requested resource location to the URL
10 $url.= $_SERVER['REQUEST_URI'];
11
12 echo $url;
13 ?>
1$protocol = strpos(strtolower($_SERVER['SERVER_PROTOCOL']),'https') === FALSE ? 'http' : 'https';
2$host = $_SERVER['HTTP_HOST'];
3$script = $_SERVER['SCRIPT_NAME'];
4$params = $_SERVER['QUERY_STRING'];
5
6$currentUrl = $protocol . '://' . $host . $script . '?' . $params;
7
8echo $currentUrl;