Current URL with PHP

Submitted by:David Villa

Date added:19 February, 2013

Category:PHP

A small function to find the current URL of the page

Tags: php function

Code Snippet:

<?
function getCurrentPage() {
$domain .= "http://";
$domain .= $_SERVER['HTTP_HOST'];
$domain .= $_SERVER['REQUEST_URI'];
return $domain;
}

echo "The current URL is: ".getCurrentPage()."!";
?>
 
 

Comments