What is the function in PHP to display and later parse the URL of the current page?
To display and parse the URL of the current page in PHP, you can use the $_SERVER['REQUEST_URI'] superglobal variable. This variable contains the path and query string of the current URL. You can then use functions like parse_url() to parse the URL and extract specific components such as the hostname, path, query string, etc.
// Display the current URL
$currentUrl = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
echo $currentUrl;
// Parse the current URL
$urlComponents = parse_url($currentUrl);
echo "Scheme: " . $urlComponents['scheme'] . "<br>";
echo "Host: " . $urlComponents['host'] . "<br>";
echo "Path: " . $urlComponents['path'] . "<br>";
echo "Query String: " . $urlComponents['query'] . "<br>";