Find the Current URL with PHP
Find the Current URL with PHP
=======================
URL to a current page contains in three parts:
1. Domain name
2. Path to the page
3. Query string
This information are stored in the $_SERVER array. we can get from this array.
Code:
<?php
$domain_name = $_SERVER[’HTTP_HOST’];
$path = $_SERVER[’SCRIPT_NAME’];
$query_string = $_SERVER[’QUERY_STRING’];
$url = “http://” . $domain_name . $path . “?” . $query_string;
echo “URL: ” . $url . “<br />”;
?>
