How to Get the Full URL in PHP

Created
Modified

Using $_SERVER Variable

$_SERVER is an array containing information such as headers, paths, and script locations.

The following example should cover whatever you are trying to do:

$link = "//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";

// escaped
$link = htmlspecialchars($link, ENT_QUOTES, 'UTF-8');
echo $link;
//installmd.com/code/php/hash.php?p=1

Related Tags

#url#