PHP

Learn How To Find The Current URL In PHP
Get the self URL of current page
some times you need to print the url of the current page for many reasons such as for social bookmarking situation and so on.
now we will learn how we can print the url with simple code
first you must add this two function to your functions

the function

function selfurl() {
    $s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s": "";
    $protocol = strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s;
    $port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]);
return $protocol."://".$_SERVER['SERVER_NAME'].$port.$_SERVER['REQUEST_URI'];
}

function strleft($s1,$s2) {
    return substr($s1, 0, strpos($s1, $s2));
}

Usage

its very simple just use some thing like this:
echo 'The Page Url Is:'.selfurl();
in: » Website Programming » PHP | Posted on Oct 17th, 2009 | last update on May 16th, 2010 | views 3,270
About the author
i'm moustafa from egypt i love doing one thing 'web programming & designing', This year I've got 19 years old and i'm in the english College of management (in Business Administration part soon)